1

嗨,我已经为软件alfresco编写了一个 spring surf 表单扩展,在特定的下拉列表中,我想以动态方式将值放在从alfresco此处读取值或属性文件的位置myaction-share-amp-actions-extension-modules

<extension>
.................................................................
<config evaluator="string-compare" condition="signed">
       <forms>
            <form>
              <field-visibility>
                        ............................................
                        <show id="my_form_sign_firma.tipo"/>
                        ...................................     
              </field-visibility>
              <appearance>
.....................



<field id="my_form_sign_firma.tipo" label-id="property.form.sign.my_form_sign_firma.tipo">  
 <control template="/org/alfresco/components/form/controls/selectone.ftl">  
<control-param name="options">${value1},${value2},${value3}</control-param>
 </control>
</field>     
....................

或替代

....................

<field id="my_form_sign_firma.tipo" label-id="property.form.sign.my_form_sign_firma.tipo"> 
<control-param name="options">${valueX}</control-param>
 <!-- where valueX= "value1,value2,value3" -->
 </control>
</field>
....................  
                        </appearance>
                    </form>
                </forms>
            </config> 

...........................................

</extension>

并且在文件上设置了用于加载属性的 bean share-config.xml

<bean id="configurazioniBeanCompletoLocale" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:it/test/properties/myalfresco.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="propertiesPersister">
 <bean class="org.alfresco.config.AlfrescoPropertiesPersister" />
</property>
</bean>

并且在文件上设置了属性share-config.xml文件:

classpath*:it/test/properties/myalfresco.properties

该文件myalfresco.properties包含:

value1=hello
value2=hi
value3=goodbye
valueX=hello,hi,goodbye

或者,如果有人知道该怎么做,我可以接受在露天使用特定文件的属性,例如:

Repository/Data Dictionary/configuration.txt具有方面“配置器”的属性,具有以下属性:

value1=hello
value2=hi
value3=goodbye
valueX=hello,hi,goodbye

有办法做到这些吗?

更新:

我现在将尝试在此链接上写一个完整的解决方案: https ://community.alfresco.com/thread/233246-how-setup-spring-surf-form-with-dinamic-variables-from-a-properties -文件

在这里您可以找到与此案例类似的另一个示例:https ://community.alfresco.com/thread/209460-dynamic-selectone-in-alfresco-share

4

2 回答 2

2

As said by Vikash, I would suggest you to create your custom form control (put it in the src/main/amp/config/alfresco/web-extension/site-webscripts/org /alfresco /components/form/controls/mycontrol.ftl folder).

Inside, you will call a custom webscript you created (which will get the values of your file). This is the trivial part, I don't feel the need to show you an example.

You can look at this (simplified) example for the ftl part :

...
<select id="${fieldHtmlId}" name="${field.name}" tabindex="0"
     <#if field.description??>title="${field.description}"</#if>
</select>
...
<script type="text/javascript">//<![CDATA[
YAHOO.util.Event.onContentReady("${fieldHtmlId}", function ()
{
    Alfresco.util.Ajax.jsonGet({
        url: encodeURI(Alfresco.constants.PROXY_URI + '/myserviceuri'),
        successCallback:
        {
            fn: function loadWebscript_successCallback(response, config)
            {
                var obj = eval('(' + response.serverResponse.responseText + ')');
                if (obj)
                {
                    for (i = 0; i < obj.length; i++) {
                            var newOption = document.createElement('option');
                            newOption.value = obj[i].id;
                            newOption.text = obj[i].name;
                            YAHOO.util.Dom.get("${fieldHtmlId}").options.add(newOption);
                    }
                }
            }
        }
    });

}, this);
//]]></script>

You can then use it this way :

<field id="my_form_sign_firma.tipo" label-id="property.form.sign.my_form_sign_firma.tipo">  
 <control template="/org/alfresco/components/form/controls/mycontrol.ftl">
 </control>
</field>  
于 2017-09-27T14:47:20.527 回答
1

您可以使用自定义 ftl 文件作为表单控件

以共享形式提供自定义 ftl 文件的模板路径

 <form>
         <appearance>
            <field id="cm:name">
               <control template="/my-textfield.ftl" />
            </field>
         </appearance>
      </form>

请参阅本文档

于 2017-09-27T10:19:22.937 回答