You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sonu S <so...@gmail.com> on 2008/03/29 13:15:15 UTC

struts- validation messages

Hi,

I am using struts in my application. to validate users entry in jsp i have
my validation method. and i am calling that method in action class. code is
below:(I am not using struts' validations )

//  in action class, calling validate method
ActionErrors errors = myForm.validate(mapping,request);


//In form bean
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request) {
        ActionErrors errors = new ActionErrors();
        if(("".equals(name.trim()))){
            errors.add(name, new ActionError("myForm.Name"));
        }
        if(("".equals(address.trim()))){
            errors.add(address, new ActionError("myForm.address"));
        }
        return errors;
    }



// in action class checking is errors are empty
if (!errors.isEmpty()) {
    saveErrors(request, errors);
    return mapping.findForward("ADD");
}


above code is working fine. Only problem is it is printing error messages in
jsp in one line.

example: Enter Name. Enter Address.


I would like to show every error message on new line in jsp. is it possible.


in jsp i am using <html:errors/> to print message.


thank you for your time and solutions

Re: struts- validation messages

Posted by Nuwan Chandrasoma <my...@gmail.com>.
http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html

Thanks,

Nuwan


Sonu S wrote:
> Hi,
>
> I am using struts in my application. to validate users entry in jsp i have
> my validation method. and i am calling that method in action class. code is
> below:(I am not using struts' validations )
>
> //  in action class, calling validate method
> ActionErrors errors = myForm.validate(mapping,request);
>
>
> //In form bean
> public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> request) {
>         ActionErrors errors = new ActionErrors();
>         if(("".equals(name.trim()))){
>             errors.add(name, new ActionError("myForm.Name"));
>         }
>         if(("".equals(address.trim()))){
>             errors.add(address, new ActionError("myForm.address"));
>         }
>         return errors;
>     }
>
>
>
> // in action class checking is errors are empty
> if (!errors.isEmpty()) {
>     saveErrors(request, errors);
>     return mapping.findForward("ADD");
> }
>
>
> above code is working fine. Only problem is it is printing error messages in
> jsp in one line.
>
> example: Enter Name. Enter Address.
>
>
> I would like to show every error message on new line in jsp. is it possible.
>
>
> in jsp i am using <html:errors/> to print message.
>
>
> thank you for your time and solutions
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org