You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tim Azzopardi <ti...@tigerfive.com> on 2007/02/26 23:26:52 UTC

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

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? 


-- 
View this message in context: http://www.nabble.com/s2--Is-this-a-sensible-way-of-doing-in-line-editing-in-a-table--tf3296620.html#a9170727
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by Roger Varley <ro...@googlemail.com>.
Following on from this, could anyone point me towards a
tutorial/example code on how to deal with an indexed edit technique
when I also need to use paging. For example, I have to do a similair
thing to the OP however I am restricted to editing 10 lines per page.
This would be easy if I could pass start and end values to the
<s:iterator> tag from my action class, but I can't see how to do that.
The only other way I can see to do this is to have both a full list of
line items and a smaller "current page" list that are maintained in my
action class.

Regards

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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

Posted by Mark Menard <ma...@mjm.net>.
Hi Tim,


On 2/26/07 5:26 PM, "Tim Azzopardi" <ti...@tigerfive.com> wrote:
> (I'm using a heaviliy modified xhtml theme that required me to use explicit
> <tr> tags in case anybody is wondering)

First take a look at http://www.vitarara.org/cms/node/85 and see if that
might eliminate the need for you to do explicit <tr> tags.
 
> 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!

This will work fine, as long as you save the collection in a conversation or
the session between hits, or the ordering of the collection is determinant
and you can always assure that element 0 will always be the same. You
probably already know all of that, but just in case.
  
> 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)?

Take a look at http://www.vitarara.org/cms/node/81. That ought to work
around your issue. This would always have you indexing back to an entity by
id in the backing Map. It's safer than just indexing into an ordered
collection.
 
> Also, is there a way of using the struts2 field validation framework with
> multiple fields? 

You got me on that one. I've done some validation in this style, but the
validation error needs to reference the generated name of the field to get
the error back to the right place.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org