如何设置弹簧冲浪形式Alfresco与属性文件中的dinamic变量共享

时间:2017-09-27 08:18:59

标签: java share alfresco alfresco-share spring-surf

您好我已经为软件alfresco编写了一个spring spring表单扩展,在特定的下拉列表中,我希望将值放在从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具有属性为“Configurator”的属性:

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

您可以在此处找到与此案例类似的其他示例:https://community.alfresco.com/thread/209460-dynamic-selectone-in-alfresco-share

2 个答案:

答案 0 :(得分:1)

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

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

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

请参阅此Documentation

答案 1 :(得分:1)

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

在里面,您将调用您创建的自定义webscript(将获取您文件的值)。这是微不足道的部分,我觉得不需要向你展示一个例子。

您可以查看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>