struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew J. Vincent" <>
Subject ActionForm.validate() Help
Date Wed, 01 Sep 2004 16:35:44 GMT
Hello all,

I just downloaded the latest stable build of Struts 1.2.  What is a 
"best practice" approach of handling validation in the ActionForm's 
validate method since ActionError was deprecated? 
Also, how should one display the messages in the JSP?  Currently I use:

<logic:messagesPresent message="true">
    <html:messages id="message" message="true">

Howver this does not display anything when I use the following code in 
my ActionForm because errors is obviously not populated with any data:

    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {

        ActionErrors errors = new ActionErrors();
        if (/*some error occurs*/){
            ActionMessages messages = new ActionMessages();
            ActionMessage message = new 
            messages.add(ActionMessages.GLOBAL_MESSAGE, message);
            request.setAttribute("warnings", messages);
        return errors;

However in an Action the following code will work correctly and display 
in the HTML rendered by the JSP code from above:

            ActionMessages messages = new ActionMessages();
            ActionMessage message = new ActionMessage("errors.notfound");
            messages.add(ActionMessages.GLOBAL_MESSAGE, message);
            saveMessages(request, messages);

Do I have to check for the existence of both messages and errors in the JSP?



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message