Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

ActionMessages?????????

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody
I am working on a struts 1.2.4.
I want to know how we can use ActionMessages and pull them by
<html:messages> tag.
This is what I tried but not working
Following is the code of a validate method of a formbean

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)
{
ActionMessage msg = null;
ActionErrors errors = new ActionErrors();
ActionMessages messages=new ActionMessages();
if (getLoginID() == null || getLoginID().length() < 1)
{
msg = new ActionMessage("errors.loginID.required");
//errors.add(ActionMessages.GLOBAL_MESSAGE,msg );
messages.add(ActionMessages.GLOBAL_MESSAGE,msg );

}
if (getPassword() == null || getPassword().length() < 1)
{
msg = new ActionMessage("errors.password.required");
// errors.add(ActionMessages.GLOBAL_MESSAGE,msg );
messages.add(ActionMessages.GLOBAL_MESSAGE,msg );
}

return errors;
}

and my jsp is
<html:messages id="error" message="true">
<li><bean:write name="error"/></li>
</html:messages>
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't seen ActionMessages used as part of an action form's validate method. As far as I know, unless you return a list of ActionErrors, nothing will be saved to the request for processing by the input page. In order to see the ActionMessages in action, I would suggest that you create a single action in which you do the following:


Make sure that your struts-config for the page you want to forward to has

redirect

set to false, and that the page itself has the tag.
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic