This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Passing values to form bean string array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing values to form bean string array" Watch "Passing values to form bean string array" New topic
Author

Passing values to form bean string array

Sw Kala
Greenhorn

Joined: Jan 12, 2010
Posts: 5
Hi,

I am unable to pass values to form bean string array from a jsp in which I have incorporated dynamically adding of textboxes in javascript.
Please do reply for my query, I need this very urgent .

I posted the query in another forum but did not get any reply


Java Begineer
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Is this question about Struts form beans?? You've not mentioned it but it seems likely to me...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Sw Kala
Greenhorn

Joined: Jan 12, 2010
Posts: 5
Yes, I am talking about struts form bean. Can you help?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Since the question is about Struts, it should be the the Struts forum. Please read this...
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

If there are multiple text boxes in your JSP with the same name i.e. the same value in the name attribute, then it should not be hard to transfer that to the form bean. The form bean just needs to have a String[] with the same name as the name of the text boxes...
Sw Kala
Greenhorn

Joined: Jan 12, 2010
Posts: 5
Hi,

I have given add/delete row option in the jsp. If there is single row, this is working fine. But after adding a row, I am not able to either do any validations on added textboxes or pass the values to the String array form bean variable.
code snippet:

Please help.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

please Use Code Tags when you post a source code. That way your code looks formatted. Unformatted code is hard to read. You can add code tags by wrapping your code in [code] [/code] tags. You can edit your message using button and then add code tags to it.


Here I hope that you are not applying the onchange event to the newly created input field as you are assigning the onchange event to element4 instead of element5.

As far as my limited knowledge of Struts 1.x goes, it should've worked. I can't say why it didn't work...
Sw Kala
Greenhorn

Joined: Jan 12, 2010
Posts: 5
Onchange event is not the issue, I am talking about how to pass value of this qty field into string array in form bean.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Please read this. You've posted the same question here...
Sw Kala
Greenhorn

Joined: Jan 12, 2010
Posts: 5
I did not get any reply there....Can you help on this query??
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing values to form bean string array
 
Similar Threads
2d arrays and form bean
Validate Arrays in Validator FrameWork
BeanUtils issue
Combo box building
checkbox