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">
       ${message}<br>
   </html:messages>
</logic:messagesPresent>

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 ActionMessage("errors.valueRequired");
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?

Thanks!

Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to