If the name in the html sent to the browser is just "units" (with multiple
instances of this field) then use:
request.getParameters("units")[1]
(this method returns an array of String)
Have you looked at the nesting tutorials yet?
http://www.keyboardmonkey.com/next/index.jsp
If you use collections of nested beans (each row having one bean) you will
find life a lot easier...
-Original Message-
From: Sinclair, Mark [mailto:[EMAIL PROTECTED]
Sent: Monday, 7 July 2003 19:40
To: [EMAIL PROTECTED]
Subject: Multiple updates to objects from a table list
Hi folks,
I have a question - however the root cause of the question may be because I
am not understanding the best way to use the Form Beans and the Actions for
updating multiple objects from one screen.
Basically I have a jsp that displays a table list of objects (ItemType). I
pass an ItemTypes ArrayList to the jsp (in the session) and use a
logic:iterate to print out the HTML. Each printed ItemType row also needs
to have a check box and a couple of text boxes to accept input if needed.
Rather than use an edit hyperlink for each row to a separate screen - if
the check box is checked for the row when the form is submitted (after
validation) it needs to read the values for the text boxes and update for
the relevant fields for the ItemType in the DB and repeat for all checked
rows.
Since I need to capture input I use text boxes, the property attribute needs
to be present so my jsp FormBean has properties e.g. rate and units that
will correspond to the values that need to be read? So each time I output
the row in the iterate to draw the text box I use
where units is an int in my FormBean. (In my formBean units is not an array
- should it be?)
Also, I cannot seem to read the units array from the request in the validate
of the FormBean I have tried
request.getParameter("units[1]");
request.getParameter("units(1)]"); both return null.
and several other variations. Does anybody know the correct way to get at
the units text box array?
I am trying to get the basics working for now and then this will be expanded
to test if check box is checked then process each row together.
All other struts examples I have seen present a list then use a separate
screen to edit each row and return to the list with updated values. I may
have several item on the list all needing rates and units entered and would
be much more user friendly to process at once.
So, more importantly is there a better way to construct this, this must have
been done many times before? - any examples would be much appreciated.
This is probably as clear as mud but thanks in advance,
Mark
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]