• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reload request level lists after validation

 
Fletcher Munson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Struts 2, and I have a number of fields on which I perform some basic validation. Upon submission everything goes to the MyClass-validations.xml and the fields fail/pass. When they pass everything is rosey, but when they fail I get exceptions. The root of this is that I have a list that is retrieved by another action on page load. What I need to know is - is there a way to get hang on to this request level list for reuse if validation fails? Thanks in advance.
 
Fletcher Munson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've resolved this by using the validate method.



pretty simple
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FWIW, you could just have a getter in the action that returns the list and skip putting it in the request altogether.

That has the side benefit of taking non-validation stuff out of the validate() method.
 
Fletcher Munson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm entering transactions for an accounting system, and I need to retrieve the list based on the type of transaction. I use an initial action on page load to determine what the list will contain. I need to perform the same assessment during validation. If I just use a getter I didn't think the jsp would know about the type when it renders the page. Or am I wrong?

This brings me to my next question which I think should be a new topic.

Please take a look:

http://www.coderanch.com/t/428245/Struts/Using-multiple-JSPs-one-Action
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic