customize struts error messages

Posted on 2007-10-20
Last Modified: 2013-11-24
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
Question by:jagadeesh_motamarri
    LVL 16

    Expert Comment

    Try this

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

    Accepted Solution

    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>
    LVL 16

    Expert Comment

    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>

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Java 1603 Error 2 26
    userCompare  challenge 3 54
    allStar challenge 1 27
    java  and programming certification ? 4 29
    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now