Updating Lists of Lists in Tapestry4 using textfields and a single submit button
Posted
by Nicolas Scarrci
on Stack Overflow
See other posts from Stack Overflow
or by Nicolas Scarrci
Published on 2010-04-14T17:11:05Z
Indexed on
2010/04/14
17:13 UTC
Read the original article
Hit count: 614
In Tapestry 4 I am trying it iterate over a list of lists (technically a list of objects who have a list of strings as a data field). I am currently doing this by using 'nested' for components.
(This is pseudo code)
<span jwcid="Form">
<span jwcid="@For" source="ognl:Javaclass.TopLevelList" value="ognl:SecondLevelList" index="ognl:index">
<span jwcid="@For" source="ognl:SecondLevelList.List" value="ognl:ListItem" index="ListItemIndex">
<span jwcid="@TextField" value="ognl:ListItem"/>
<span jwcid="@Submit" listener="ognl:listeners.onSubmit"/>
</span></span></span>
The onSubmit listener then accesses the index and ListItem index page properties, as well as the ListItem page property in order to correctly update the list in Javaclass.TopLevelList.
This works fine, but it looks terrible, and is cumbersome to the end user. I would prefer to somehow simulate this functionality using only one submit button at the bottom of the page.
I have looked into somehow using the overlying form component to obtain a list of the 'form control components' within it, and then (with great care) parsing through tapestry's naming conventions to recover the functionality of the indexes.
If anyone knows how to do this, or could explain the form component (how/when it submits, etc.) it would be greatly appreciated.
© Stack Overflow or respective owner