• 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

bean:write does not work properly on validation

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

My Jsp page has these this code and I am using struts validation.

<TD class="left">Applicant Name:</TD>
<TD class="left"><bean:write name="RqstForm" property="applName" /></TD>

My validation part works fine, it displays the errors when OK is clicked. But all the <bean:write> values on my page disappear after the page is re-loaded.

So before clicking OK it looks:
Applicant Name:Johny Hudson

After clicking OK it looks:
Applicant Name:

The value "Johny Hudson" disappears. But the <html:text> values appear to be fine.

Please help. Thanks for your time.

Luke.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Luke,
RqstForm sounds like a form in the HttpRequest scope. This scope is wiped clean on a new request/trip to server. After the validation, you are on a new request and the data is gone.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne is absolutely right. However, I'm guessing the next question in your mind is "so now what do I do?".

One way to do it would be to add a hidden field to your page like this:

If you do this, the "applName" property will get submitted along with the form and will be added to your ActionForm when the validation fails. It will then show up on your JSP just like the other input fields do.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill's suggestion is the easiest and it works great for small sets of data. You will find that you encounter the same issue for the lists used to populate list boxes. If you have a lot of data or if you have lists of data the solution that I use is to have the input attribute of your action mapping point to an action that can populate these values on your form.

- Brent
 
Luke Zechariah
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne, thank you very much in clearing me the concept on what really happens on the background.

Merrill, I would really go ahead with your suggestion, per Brent's recomendation as it has less chunk of data. Thank you.

Brent, I did have the problem a while ago and did not know which way to proceed. So I put the whole arraylist in a session scope. But thank you, that is a good suggestion.

Thanks everyone once again, its working the way it was desired.
Luke.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic