Struts { { { ActionErrors } } }class comes very handy in resolving the first issue of stacking messages of different category. To throw error messages of different category use an interface to define all the different category of message like FATAL, ERROR, WARNING, INFO etc. Then in the Action or { { { ActionForm } } } class you can use

errors.add("Message.FATAL", new ActionError("...."));
errors.add("Message.ERROR", new ActionError("...."));
errors.add("Message.WARN", new ActionError("...."));
errors.add("Message.INFO", new ActionError("...."));

saveErrors(request,errors)

Then in the JSP page you can recognize them by

<logic:messagePresent property="<%=Action.ERROR_KEY%>"> 
{{{  <html:messages property="<%=Action.ERROR_KEY%>" id=”error” > 
    showError(‘<bean:write name="error"/>’); // JavaScript Function 
  </html:messages> 

</logic:messagePresent >

--Puneet Agarwal


Comments

StrutsCatalogErrorTypes (last edited 2009-09-20 23:32:03 by localhost)