• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 727
  • Last Modified:

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
0
jagadeesh_motamarri
Asked:
jagadeesh_motamarri
  • 3
1 Solution
 
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:
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:
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now