• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts form not holding values

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am certain it is me missing something blatently obvious, but can anyone offer me any ideas as to why my form won't hold the values after I submit the page ? I have a page where I search for users, the page is then given back a list. I want to be able to modify the users permissions and then submit the page and have the changes take effect, but when I submit the page there is nothing for the action to work on - the data seems to have been lost along the way.

Any thoughts ?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if this is the problem or not, but I'd suggest you read the FAQ entry on indexed properties (question 6).
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many things will cause this problem. I think you may give some reference codes,then others can help you.
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I am working through it now, the issue that is causing me particular grief is working with checkboxes. I will put an update in here when I make some more headway, or if I run into another issue. Again thanks for the help.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What scope are you using? If your action mapping is using request scope then keep in mind that when your page is submitted a brand new instance of your action form is created and the only fields populated will be the fields submitted as part of the page. This includes fields on your page like text boxes, checkboxes and hidden fields but it does not include values that are just displayed on the screen (such as from c ut or bean:write). If you only have a few fields, you can define them using hidden fields. If you have lots of data then you might have to run the search again.

- Brent
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(Firstly please let me know if I am using any terms incorrectly, as I often find that I seem to use terms that aren't the generally accepted terms and I am trying to learn all I can ). The scope is request. I am setting the values of the fields each time the page is requested. I know it's something simple that I am missing, as you helped me with a similiar issue in the past. I now have the form to the point where it will start out as false, will allow me to set it to true submit the page and retain that information, but subsequently attempting to set the checkbox back to false does not work. As there is minimal amounts of data involved in this case, I suspect a hidden checkbox would be sufficient. Is it simply a matter of putting a checkbox with the same info only putting hidden instead of checkbox in the tags ?

I have continued to play with the application and discovered something.
Submitting the form several times with the value of false and the form remains false. Submitting one true and then either true or false afterwards always remains true. For this reason I suspect it's an issue with resetting the value of the checkbox upon completion. Is there any quirks with regards to checkboxes ? In the value field should I be putting in something like bean:write individual value of checkbox - or is leaving it blank sufficient ?

thanks as always.
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So my issue seems to fall down to the fact that I don't have anything in the reset of the bean form. It seems the only way to go about recognizing that a value has been reset is if you first set them all to false. Does that make sense ? I am going based on the docs of the checkbox in struts.

thanks again.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right...you need to set the values to false in your reset method...if you are using session scope. When using request scope then a brand new instance of your form is created and the value is set to whatever you do in your constructor (or the declaration of the property). The scope is set by the scope attribute on your action mapping. The default scope is session (though that can be changed).

- Brent
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brent Sterling:
Right...you need to set the values to false in your reset method...if you are using session scope. When using request scope then a brand new instance of your form is created and the value is set to whatever you do in your constructor (or the declaration of the property). The scope is set by the scope attribute on your action mapping. The default scope is session (though that can be changed).

- Brent


I am using request scope (the value set in struts config for the action I have scope="request") so unless I am way off that is request scope. I suspect most of my confusion is due to the fact that I am not working with the property directly as it is in a list. I am going to attempt to test a few more things.

thanks again for the help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic