【问题标题】:Alfresco FormService Fundamental WRONGAlfresco FormService Fundamental 错误
【发布时间】:2012-09-10 08:00:14
【问题描述】:

Alfresco Forms Service 无法正常工作。

看起来基本的表单功能不会将表单配置 (control-param name="nameHere") 传递给 webscript。

我一步一步地重现它。

  • 创建 Freemarker 模板并根据 /share 项目下的文档进行注册。组件渲染并显示成功。一切正常。

  • 根据 wiki 表单页面上的文档创建表单。 将其注册到<TOMCAT_INST/shared/classes/alfresco/web- extension/myclok-form-config.xml> 目录并以如下方式传递给加载:

    <bean id="sampleShareConfig" class="org.springframework.extensions.config.ConfigBootstrap" init-method="register">
      <property name="configService" ref="web.config" />
      <property name="configs">
      <list>
        <value>classpath:alfresco/web-extension/myclok-form-config.xml</value>
      </list>
      </property>
    </bean>
    <!-- ... share/WEB-INF/classes/org/springframework/extensions/surf/bootstrap/forms-bootstrap-context.xml -->
    

表格实例:

<config>
 <forms>
  <form id="myclok">
   <view-form template="/org/alfresco/components/myclok/myclok.get.html.ftl" />
   <edit-form template="/org/alfresco/components/myclok/myclok.get.html.ftl" />
   <create-form template="/org/alfresco/components/myclok/myclok.get.html.ftl" />

   <field-visibility>
    <show id="currentPath" />
   </field-visibility>
   <appearance>
    <field id="currentPath">
     <control name="currentPath" template="/org/alfresco/components/myclok/myclok.get.html.ftl">
     <control-param name="currentPath">sampleData1</control-param>
     </control>
    </field>    
    <control name="currentPath" template="/org/alfresco/components/myclok/myclok.get.html.ftl">
    <control-param name="currentPath">sampleData2</control-param>
    </control>
    </appearance>
   </form>
  </forms>
</config>

在官方文档中是这样写的:

如果表单元素存在于配置元素中而没有 评估器和条件总是找到表格,这在以下情况下很有用 您希望某个字段出现在应用程序的每个表单上。

所以,我在 myclok-form-config.xml 文件中指定了它,但是这种方法没有给出任何结果。因此,当通过以下 URL http://localhost:8080/share/page/site/wcmqs/myclok> 加载具有此类对参数的引用的组件时,Alfresco 将失败并出现异常:

Exception: freemarker.core.InvalidReferenceException - Expression field is undefined on line 6, column 6 in org/alfresco/components/myclok/myclok.get.html.ftl.
freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135)
freemarker.core.Dot._getAsTemplateModel(Dot.java:78)

换句话说,不可能接收到在FormConfigs 中定义的currentPath 参数的值。 因此,FormsService / ConfigService 的最小功能不起作用。

<#if field.control.params.currentPath??>
  <#assign path=field.control.params.currentPath>
<#else>
  <#assign path="someOtherDataValue">
</#if>

有谁知道如何解决它或者可以演示一个工作示例?

PS:以上所有FormService形式的配置和webscript组件都附上。 只需调用以下命令即可快速安装 .AMP 文件:

java -jar alfresco-mmt.jar install myclokStubFormComponent.amp ../tomcat/webapps/share.war

AMP fileConfig file.

【问题讨论】:

  • 由于您的文件myclok.get.html.ftl中出现错误,请您发布该文件的内容吗?

标签: alfresco alfresco-share


【解决方案1】:

我认为您误解了表单模板和字段模板之间的区别。您正在指定相同的文件 /org/alfresco/components/myclok/myclok.get.html.ftl 来控制表单的布局以及呈现您的字段。

当您使用字段模板呈现表单时,您会收到一条错误消息,指出尚未填充 field 对象。这是非常正确的,因为框架还没有开始渲染各个字段。您正在渲染表单。

我建议您在开始实现自己的更复杂的表单之前尝试一些更基本的示例,例如表单开发工具包 (FDK) 附带的示例,并且尤其是在您开始声明之前该框架没有按文档说明工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    相关资源
    最近更新 更多