• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Struts 1.1: ActionErrors between different Actions

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form (form.jsp) and a connected FormAction ActionA. ActionA does validations and stores ActionErrors and the form.jsp will print them using <html:errors../> tag.
All this is working fine.

I then wanted to add some on-the-fly server side validation on onblur event on one of the form fields (fieldA). It goes to a different Action class (ActionB) which will return a value, that I can print in a div under fieldA. This also works fine.

The problem is to combine the two. I use saveErrors method in ActionA and need to reset it with the new errors I get in ActionB.

Example: If fieldA was value "A" and fieldB was "#$" and my ActionA returned errors "No capitals for fieldA" and "No symbols for fieldB" on pressing Submit, then when user changes fieldA to "123" and presses tab, the errors shown should be "No numbers for fieldA" and "No symbols for fieldB" i.e. first error gets removed.

But how do I access the errors, if it isn't in the request!
Ranch Hand
Posts: 123
Firefox Browser Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that is the nature of the 'request' context. there is a new one for each request from client - therefore also dont have the previous request's data.

struts or not, that is how request context works.

look into session context for additional knowledge.

since the validation is shared by more than 1 action, if this is my problem, i would create a separate class whose purpose is validation of ENTIRE form. this class will be used by both struts action classes you mentioned.
    Bookmark Topic Watch Topic
  • New Topic