customize struts error messages

Hi -

here is my sample code for displaying the struts error messages -


                                    <table width="554" cellpadding="0" cellspacing="0">
                                                <div class="errors"><bean:message key="errors.header" />
                                                      <html:messages id="error">
                                                            <li><bean:write name="error"  /></li>

But in order to apply some style to my error messages i need to pass the errors to the below customized tag into the message parameter.

            <ecp:ErrorControlGrouping errorType="errorMessageCritical" id="translationPopUp"
  message="Struts Error Messages should go into here as a string"'  > </ecp:ErrorControlGrouping>            

how can i achieve this?

Thank You
LVL 10
Who is Participating?
Forgot the above .. and try this

<bean:define id="sErrorHeader" name="org.apache.struts.action.MESSAGE" parameter="errors.header" type="java.lang.String"/>
<ecp:ErrorControlGrouping errorType="errorMessageCritical" id="translationPopUp"
  message="<%= sErrorHeader %>"  > </ecp:ErrorControlGrouping>
Try this

<ecp:ErrorControlGrouping errorType="errorMessageCritical" id="translationPopUp"
  message="<%= ((MessageResources)reqest.getAttribute("org.apache.struts.action.MESSAGE")).getMessage("") %>"  > </ecp:ErrorControlGrouping>
Or this

<bean:define id="messages" name="org.apache.struts.action.MESSAGE" type="org.apache.struts.util.MessageResources" scope="application"/>
<ecp:ErrorControlGrouping errorType="errorMessageCritical" id="translationPopUp"
  message="<%= messages.getMessage("errors.header")%>"  > </ecp:ErrorControlGrouping>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.