Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

s2] Is this a sensible way of doing in-line editing in a table?

Tim Azzopardi

2007-02-26

Replies:


I'm doing in line table editing and it works.

Here's a (very) cut down version of my form. The code displays a
form/table, where each line in the table corresponds to an element/item in
the prLines collection of the action.

<s:form name="savePurchaseRequest" action="savePurchaseRequest"
method="post" validate="false" theme="xhtml">

<s:iterator value="prLines" status="status">
 <tr>
 
   <s:set name="zi" value="#status.index" scope="request"/>
   
   <s:label value="%{partNm}"/>      
   <s:label value="%{supplierNm}"/>      

   <s:textfield name="prLines[${zi}].quantity" value="%{quantity}" size="8">
     <s:param name="after">
       <s:hidden name="prLines[${zi}].partId" value="%{partId}"/>
     </s:param>
   </s:textfield>

   <s:textfield name="prLines[${zi}].internalComments"
value="%{internalComments}" />
 </tr>
</s:iterator>

</s:form>

(I'm using a heaviliy modified xhtml theme that required me to use explicit
<tr> tags in case anybody is wondering)

This generates, for example, for one of the fields in the the table
 <s:textfield name="prLines[0].quantity" value="23" size="8">

And this works a treat, populating the collection in the action. Great!

But I was hoping that generating the simpler html
 <s:textfield name="prLines[].quantity" value="23" size="8">
would work but it doesn't seem to create anything in action.

Generating the indexes is not that hard, but I'm in a situation now where I
am moving rows from one table to another via dhtml and of course managing
the indexes is fiddly.

Is there a better/simpler way of managing multiple fields (possibly without
being forced to maintain the indices)?

Also, is there a way of using the struts2 field validation framework with
multiple fields?


--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.