I did have a mail with a whole spiel as to how to go about it, but then 
thought that it wouldn't take long and be more of help if there was a 
"scratch-n-sniff" example you could go through also, so the solution is 
attached (requires everything needed to run Struts and the nested 
extension in the /WEB-INF/lib dir. Nightly build has it all, or older 
Struts with the nested extension's jar ( 
http://www.keyboardmonkey.com/struts )).

How it goes about it...
...in the list, the rows are marked up from separate objects in a list 
and each has a submit button.
When one is clicked, because of the underlying nested property, the 
individual objects' setter for the submit button will be called when the 
form goes back to the struts servlet. From this setter it tells the root 
bean that it's now to go to edit mode and set a standard property 
("editingObject") in the root bean to return the object to be edited. 
Then the action goes to the edit page which edits any object under the 
"editingObject" property. Submit this form and it will update bean, the 
action will set everything back, and there you have it.

When you consider this is the sum total of the entire process it's 
really quite simple. And no hidden input fields or javascripts.

If you're not running the nightly build, get the nested extension from 
here...
http://www.keyboardmonkey.com/struts

Another example using "edit view" style functionality...
http://www.keyboardmonkey.com/StrutMonkey/MonkeyStruts_v2.jsp

For all the info you want about the nested extension, go to the "/struts 
" link above.



Arron.


David M. Karr wrote:

>>>>>>"Larry" == Larry Maturo <Maturo> writes:
>>>>>>
>
>    Larry> I have a table that displays information on a number of
>    Larry> items.  Each table entry has an edit button, so that you
>    Larry> can edit the information on that item. I use an iterate 
>    Larry> tag to populate the table.  My problem is that I don't
>    Larry> know how to save something indicating which edit button
>    Larry> they pressed.
>
>    Larry> My best guess was to use an onclick handler to set a
>    Larry> hidden variable.  My problem is that while I know how
>    Larry> to create the hidden variable (using the struts hidden
>    Larry> tag) I don't know how to set it in the onclick handler.
>
>One approach is not to try to determine which edit button was pressed, but to
>use a hidden field in a form in each table row to encode the OID of the object
>in that row.  Each form row submits to the same action.
>




Attachment: nested-object-editor.war
Description: Binary data

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

Reply via email to