On Dec 11, 2008, at 10:42 PM, Nils-Helge Garli Hegvik wrote:
The s:form equivalent of the nested-example above should be
something like:
<s:form name="myForm">
<s:push value="person.address">
<s:textfield name="street"/>
</s:push>
</s:form>
Wouldn't <s:textfield name="person.address.street"> to the trick?
Yes, but what if you want to reuse code for the form fields for an
address and include another jsp? Then you always have to be nested
inside person.address, you cant reuse the code if you are inside lets
say customer.address.
When it really comes in handy is when you operate with collections.
Take this example from Struts 1:
<nested:nest property="foo">
<nested:iterate property="bars">
<nested:text property="baz"/>
</nested:iterate>
</nested:nest>
to do the same ting in Struts 2 you have to write:
<s:push value="foo">
<s:iterator value="bars" status="status">
<s:textfield name="foo.bars[%{#status.index}].baz" />
</s:iterator>
</s:push>
With some changes to the Struts 2 codebase you could write
<s:push value="foo">
<s:iterator value="bars">
<s:textfield name="baz" />
</s:iterator>
</s:push>
Andreas and I have started to get the example above working on Struts
2. We have some working code, but not all details are figured out yet.
--
Ronny Løvtangen
Senior Consultant - Net Professionals AS
ro...@net-pro.no
+47 928 21 901
http://net-pro.no
http://www.linkedin.com/in/ronnylovtangen