如何设置 spring surf form Alfresco 与属性文件中的动态变量共享

How setup spring surf form Alfresco share with dinamic variables from a properties file

您好,我已经为软件 alfresco 编写了一个 spring 冲浪表单扩展,在特定的下拉列表中,我想以动态方式读取值 [=17] =] 或此处的属性文件 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 具有方面的属性 "Configurator" 具有属性:

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

有办法做到其中之一吗?

更新:

我现在将尝试在纸上写下关于此 link 的完整解决方案: https://community.alfresco.com/thread/233246-how-setup-spring-surf-form-with-dinamic-variables-from-a-properties-file

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

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

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

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

参考这个Documentation

正如 Vikash 所说,我建议您创建自定义表单控件(将其放在 src/main/amp/config/alfresco/web-extension/site-webscripts/org /alfresco /components/form/controls/mycontrol.ftl 文件夹中)。

在内部,您将调用您创建的自定义网络脚本(它将获取您的文件的值)。这是微不足道的部分,我觉得没有必要给你看一个例子。

您可以查看 ftl 部分的这个(简化的)示例:

...
<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>

然后您可以这样使用它:

<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>