• 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

Server-side validation causing bean data to vanish.

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

I'm not sure why it's happening, but my validation causes all the data on the .jsp to erase (all integers become 0, all Strings become null) if it comes back with an error.

Here's what I have:
Maintain.jsp


I populate the bean with the following, it's in the Action that forwards to maintain.jsp


myDTO is an instance of MaintainDTO, which has the following



It works perfectly when the form first loads, but when validation returns an error, it uses all the default values of MaintainDTO.

Oddly enough, it also calls the reset method of MaintainForm.

Is there anyway I can keep my bean data safe on error?

EDIT: I don't believe I can use Client-side validation either. Part of my validation is a "requiredif" depending on the value of the radio buttons. It gets caught fine with the Server-side, but I can't seem to grab the "requiredif" conditions on switching to client-side.
[ June 01, 2004: Message edited by: Karl Beowulph ]
 
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
Karl,
Can you also post the relevant portions of your struts config file? In particular, the form and action tags for this page.
 
Karl Beowulph
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course.



Edit: I have also tried setting the scope of both my action-mappings to "session" and recieved the same outcome.
[ June 02, 2004: Message edited by: Karl Beowulph ]
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I too face the same problem of form bean resetting after a validation files. Can anyone provide a solution?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to this question is in our FAQ. See question 18.
 
Karthik Srinivas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Merrill Higginson

I went through the FAQ. But the case explained there is where there are two actions, one to display and one to process. Hence, after form validation fails, the display action is called to repopulate the bean(by fetching from database) and then the jsp is displayed.

I have a scenario like this, where there is a user registration form with around 10 fields for user input. I want to retain these values, even after a server-side validation failure. Note that there is no specific action before displaying the form.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using <html:text> tags for the fields in your JSP without value attributes? If not, that's the problem. If you are, and are still getting this problem, please post relevant portions of your JSP, Action class, ActionForm, and struts-config.xml file.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic