Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting to the JSP when validation error occurs

 
Srilakshmi Vara
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Thanks for your suggestions before.

Have another question!

I am populated a page using some database values, if user enters some values upon that and submits the form i am redirecting to .do(which populates with DB values) but i am loosing user entered values, if i redirect to the jsp i am getting null pointer exception on populated field values.

What to do in this scenario?

Thanks in advance,
Srilakshmi
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create a 3rd action mapping that is mapped to the same form-bean definition and used this new mapping (uri) as your 'input' attribute for the action where you set validation to true. in essense, you'll have 3 mappings (a bit ugly, yes):

1. /myaction/entry.do (name="MyForm") //where DB values are loaded initially

2. /myaction/submit.do (name="MyForm" validate="true" input="/myaction/failed.do") //where action is submited to

3. /myaction/failed.do (name="MyForm") //temporary uri to hold form values, needs to map this to a different action class that forwards to the same jsp/tile as #1 mapping.

this is a little easier if you have all 3 inside a DispatchAction. the only thing you'll have to do is create a 'failed' method in the DispatchAction and specify the param attribute's value to 'failed' for the input (input="/myaction/submit.do?action=failed").
[ May 16, 2005: Message edited by: alan do ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic