• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to populate formbean property using html:checkbox values

 
Poonam Kadu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I have been facing this problem since a couple of days...
I have a FormBean whose one the property is a collection of a type of objects.Using the formbean , logic:iterate and html:checkbox i could display the content in the jsp... but in the same jsp when the user changes the checboxes (check/uncheck) ...the values don't reflect in the next action..Also my form bean is in session scope...






I am expecting this to happen:
when the user checks/unchecks ...the email/sms property inside the Category bean which is the basic element of the memberAlertList ArrayList (and memberAlertList is a property of the form bean ListMemberAlertsForm) should get set...

Please advice ...

Thanks and regards
Poonam.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it rendering the way you think it should? (Note that the nested tags handle this kind of thing for you.)

I can't really read your JSP, and please, when posting code samples, remove stuff that isn't necessary, like the bizarre empty table rows.
 
Poonam Kadu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
Yes it does displays the way i want ...it looks something like a table with its last two cols as checkboxes.The checkboxes are checked/unchecked using the values from the formbean property.But when i check /uncheck and click on submit , it shows the old values of the checkbox in the new Action class . Why doesn't it show the updated values?
Sorry for the unnecesary code included.

Thanks,
Poonam
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I asked because only some of the checkboxes appear to have anything indicated they're a nested/array structure in their name, and that by looking at the rendered HTML you'd be able to determine if the names were rendering correctly.
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Poonam,

...have a look at this post, are you having the same issue?
 
Poonam Kadu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I guess its not the same problem.i dont get any null values in the next action...but i get values which were displayed before the next action was invoked.I don't know how to capture the checkbox checked/unchecked value in the boolean variable email,sms in basic element of the collection property of the formbean.
Thanks,
Poonam
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. How are you processing the response you get from the user doing next?
 
Tim Kernan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam
You may be having the same problem I am having, that is, the HTML pages is correct, indexed properties appear as the should (view html source), data is being displayed correctly.

BUT, when submitted, your ActionForm does not pick up the indexed properties. It appears that the indexed properties in the query string returned to the ActionForm are skipped over, all other properties are parsed by the ActionForm.

If this seems to be your problem, see if the query string (request.getQueryString() ) has actual brackets ("[" and "]" ) around the index or not. That is does it look like: lines%5B0%5D.name=tim or like: lines[0].name=tim ?

See my post: http://www.coderanch.com/t/508028/Struts/Struts-queryString-indexed-properties-not

I have not found a solution other that to write a parser in the Action.execute() method, which seems unnecessary. I am still looking for the right solution.

Hope this helps.
Tim
 
Poonam Kadu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
Thanks for your quick response,but its still not working
I am posting a simplified version of my problem:

struts-config.xml


ActionForm1.java


TestAction1.java


testcheck.jsp



TestAction2.java


The entry point is type /TestCheck1.do in the browser it invokes TestAction1.java action,populates TestForm1.java and forwards the request to testcheck.jsp.Inside testcheck.jsp ,when the user hits submit button it invokes TestAction2.java Action.TestForm1.java is in session scope and has been tied to both the Action classes.


Hope this example will make my problem more clear.
Thanks,
Poonam
 
Poonam Kadu
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
Thanks for your quick response,but its still not working
I am posting a simplified version of my problem:

struts-config.xml


ActionForm1.java


TestAction1.java


testcheck.jsp



TestAction2.java


The entry point is type /TestCheck1.do in the browser it invokes TestAction1.java action,populates TestForm1.java and forwards the request to testcheck.jsp.Inside testcheck.jsp ,when the user hits submit button it invokes TestAction2.java Action.TestForm1.java is in session scope and has been tied to both the Action classes.


Hope this example will make my problem more clear.
Thanks,
Poonam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic