You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian McSweeney <br...@aurium.net> on 2003/07/02 11:28:03 UTC

problems

Hi all, 

I'm trying to display errors on a jsp to which my form returns if the
data submitted is invalid. 

My form extends org.apache.struts.validator.ValidatorForm 

some fields use the validator form validation, but for custom server
side validation I overwrite the 
validate method as follows: 

   public ActionErrors validate( ActionMapping mapping,
HttpServletRequest request ) { 
       // this should call the validate on the automatic stuff 
       super.validate( mapping, request ); 
       ActionErrors errors = new ActionErrors(  ); 

       customCheck1( getFormField1(), "messagebundle.customError1",
errors ); 
       customCheck2( getFormField2(), "messagebundle.customError2",
errors ); 

       return errors; 
   } 

then in the same class I have my custom methods, eg: 

   private void customCheck1( String value, String msg, ActionErrors
errors ) { 
       if ( value.equalsIgnoreCase("whatever") { 
           String message = ResourceBundle.getBundle( "mybundle"
).getString( key ) 
           errors.add( ActionErrors.GLOBAL_ERROR , new ActionError(
message ) ); 
       } 
   } 


Now, I know this is getting called, due to debug that I have included. 
I'm successfully getting all the error messages from the resource bundle
etc. 
In my jsp I have the following tag to try to output the ActionError
messages 

<html:errors/> 

What's happening is, my jsp is being validated, but the messages just
aren't 
getting outputted. I'm getting white space where the messages should be,

and when I look at the source I see that 
<br> lines are being created for (what I assume is) each ActionError.

If anyone can give me advice/help, I'd really appreciate it. 
thanks, 
Brian