-3

Alfresco Forms Service does not work properly.

Looks like a fundamental Form functionality does not pass form configs (control-param name="nameHere") to webscripts.

I reproduce it step-by-step.

  • Create the Freemarker template and register it according to the documentation under /share project. The component renders and shows successfully. Everything works well.

  • Create a form according to the documentation on wiki Forms page. Register it in <TOMCAT_INST/shared/classes/alfresco/web- extension/myclok-form-config.xml> directory and pass it for load in such manner:

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

Form inst:

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

In official documentation is written:

If the form element exists within a config element without an evaluator and condition the form is always found, this is useful if you want a certain field to appear on EVERY form in your application.

So, I specified it in myclok-form-config.xml file, but this approach does not give any result. Thus when the component with such reference to param is loaded by the following URL <http://localhost:8080/share/page/site/wcmqs/myclok> the Alfresco fails with the Exception:

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)

In other words it's impossible to receive the value of the parameter of currentPath that is defined in FormConfigs. So, the minimal functionality of FormsService / ConfigService does not work.

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

Does anyone know how to resolve it Or can demonstrate a working sample?

PS: All above described configurations of the form of FormService and the webscript component are attached. The .AMP file for quick installation is required just to invoke the following command:

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

AMP file. Config file.

Sicco
  • 6,167
  • 5
  • 45
  • 61
Sergio Kosik
  • 192
  • 2
  • 6
  • 1
    Since the error is being thrown in your file `myclok.get.html.ftl` please can you post the contents of that file? – Will Abson Sep 10 '12 at 11:04

1 Answers1

4

I think you have mis-understood the difference betweent a form template and a field template. You are specifying the same file /org/alfresco/components/myclok/myclok.get.html.ftl to control the layout of the form as well as to render your fields.

When you use a field template to render the form you are getting an error that says the field object has not been populated. This is quite correct as the framework has not yet started to render the individual fields. You are rendering the form.

I'd suggest you try some more basic examples such as those that come with the Forms Development Kit (FDK) before you start implementing your own more complex forms, and especially before you begin to claim that the framework does not work as documented.

Will Abson
  • 1,562
  • 7
  • 13