Hello everyone,

I take part in the development of a module of Ofbiz/Neogia within the ASPerience company. I seek to dynamically define a form without passing by a ftl.

I was unable to find some issue (jira) about this functionality.

Is it possible to do something like this ? (and how is it possible ?)

This possibility was evoked by N.Malin on Neogia's wiki (http://www.neogia.org/Field_Iterate)

(this is an approximative page's transduction)

Principle:

Currently, the forms use a static definition to be able, since a context, to post information in a dynamic way. When we want to obtain a dynamically defined form, we must generally pass by screens ftl. In order to add dynamics in the forms, we can define a new iterative element which iterate on a list of map and applies each map of the list like a context to the elements contained in the iterative element.

Ex :
<form name="example" type="single" target="NewObject">
  <field name="field1" title="${uiLabelMap.Example}"><display/></field>
  <field name="field2" title="${uiLabelMap.Example2}"><text/></field>
  <field name="records">
    <iterate suffix="_it">
      <field name="field3" title="title3"><display also-hidden="true"/><field>
      <field name="field4" title="title4"><text/><field>
    </iterate>
  </field>
  <field name="submit"><submit/></field>
</form>

This form can receive a context like this:

 field1 = foo
 field2 = bar
 records = [[field3 = firstFoo, title3 = ${uiLabelMap.ExampleTitle3},
             field4 = firstBar, title4 = ${uiLabelMap.ExampleTitle4}],
            [field3 = secondFoo, title3 = ${uiLabelMap.ExampleTitle3Other},
             field4 = secondBar, title4 = ${uiLabelMap.ExampleTitle4Other}],
            [field3 = thirdFoo, title3 = ${uiLabelMap.ExampleTitle3Another},
             field4 = thirdBar,  title4 = ${uiLabelMap.ExampleTitle4Another}]]

When the modelForm reads the iterate type's field, it starts again a fields construction with each element of the list as context. One adds the attribute suffix on iterate to be able to recover the fields by a service via the List type.

Sincerely,
Eric Llusca.



Reply via email to