customize struts error messages

Hi -

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

<logic:messagesPresent>




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

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
jagadeesh_motamarriAsked:
Who is Participating?
 
gnoonCommented:
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>
0
 
gnoonCommented:
Try this

<ecp:ErrorControlGrouping errorType="errorMessageCritical" id="translationPopUp"
  message="<%= ((MessageResources)reqest.getAttribute("org.apache.struts.action.MESSAGE")).getMessage("key.to.look.up") %>"  > </ecp:ErrorControlGrouping>
0
 
gnoonCommented:
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>
0
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.