Michael Dukaczewski wrote:
[...]
<t:form>
    <div t:type="loop" t:source="items" t:value="item">
        <t:textfield value="item" />
    </div>
    <div><t:submit t:id="add" value="more"/></div>
    <div><t:submit t:id="save" value="save"/></div>
</t:form>


I have a list of values, the user has to enter. The number of values, that have to be typed in, is dynamic, so the user has to extend the form. The add button works, but the values are not saved. Can someone tell me, that I am doing wrong?

It can't work because after the loop is rendered, you don't have a conduit between list item and the textfield anymore. You should look at what is done in the beaneditorn and just use it and provide your own "listmodel", which would be a special bean model where properties are the elements of the list.

Ok, I see that I'm really clear :) Here is an example of what I've done some time ago. It is an hight level component that takes a list of "something" and create and form for it (all element of the list are editable thanks to the "something editor", an add button allow to add a blank element at the end of the list, and a delete button follow each field). (Note : it was done in an old T5 version, and should take advantage of all the new nice features like Generics in components)
The java part:
http://sventon.ow2.vservers.linagora.com/svn/showfile.svn?path=/interldap-wui-common/trunk/src/main/java/org/interldap/wui/t5lib/components/ListEditor.java&revision=HEAD&name=interldap_ow2
And the matching template :
http://sventon.ow2.vservers.linagora.com/svn/showfile.svn?path=/interldap-wui-common/trunk/src/main/resources/org/interldap/wui/t5lib/components/ListEditor.tml&revision=HEAD&name=interldap_ow2

So, the part that you want to look at is the "ListObjectBeanModelSource" :
http://sventon.ow2.vservers.linagora.com/svn/showfile.svn?path=/interldap-wui-common/trunk/src/main/java/org/interldap/wui/t5lib/data/ListObjectBeanModelSource.java&revision=HEAD&name=interldap_ow2

Ok, an real life example that build a "composed search filter" (the like you have in thunderbird when you want to search email on multiple criteria) :

http://sventon.ow2.vservers.linagora.com/svn/showfile.svn?path=/interldap-wui-common/trunk/src/main/resources/org/interldap/wui/t5lib/components/search/SearchCriterionComposition.tml&revision=HEAD&name=interldap_ow2

Each criteria is an element in the list, there is an editor for criterium added in the know editor of bean editor, and that's all ! This simple component build the form for you.

There is a big drawback: this kind of feature should be made only client side, or almost. Here, each add/remove send a request to the server...

Hope it will help !

--
Francois Armand
Etudes & Développements J2EE
Groupe Linagora - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
-----------
InterLDAP - http://interldap.org FederID - http://www.federid.org/
Open Source identities management and federation


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to