Displaying "Literal" ActionMessage in Struts 1.2.7

Hi!
Sorry, I have posted this topic before, but I haven't got an answer, so here's a second try.
I need some help concerning a new feature in Struts 1.2.7.
The ActionMessage class now has a new Constructor.
ActionMessage(java.lang.String key, boolean resource)Setting the "resource" value to "false" allows you to define a "literal"
Message without having to specify a key in the properties bundle. It will
display exactly the string that is given in the 'key' argument.
In my Action Class, I create two or more ActionMessages:
ActionErrors errors = new ActionErrors();
ActionMessage error1 = new ActionMessage("Literal Error 1", false);
errors.add(ActionMessages.GLOBAL_MESSAGE, error1);
ActionMessage error2 = new ActionMessage("Literal Error 2", false);
errors.add(ActionMessages.GLOBAL_MESSAGE, error2);
saveErrors(request, errors);In my JSP, I iterate over the ActionMessages in the follwing way:
<table>
  <html:messages id="errors">
    <tr>
      <td>
        <bean:write name="errors"/>
      </td>
    </tr>
  </html:messages>
</table>The poblem now is that in the HTML-Output, only the first Item in the Error
list appears as a literal message, whereas Struts seems to interpret the next message as a resource key:
- Literal Error 1
- ???de.Literal Error 2???
What could be the problem? Any help is appreciated!
Thanks, Ren�

Sorry, the same Message as above, now correctly formatted:
I need some help concerning a new feature in Struts 1.2.7.
The ActionMessage class now has a new Constructor
ActionMessage(java.lang.String key, boolean resource)Setting the "resource" value to "false" allows you to define a "literal"
Message without having to specify a key in the properties bundle.
In my Action Class, I create two or more ActionMessages:
ActionErrors errors = new ActionErrors();
ActionMessage error1 = new ActionMessage("Literal Error 1", false);
errors.add(ActionMessages.GLOBAL_MESSAGE, error1);
ActionMessage error2 = new ActionMessage("Literal Error 2", false);
errors.add(ActionMessages.GLOBAL_MESSAGE, error2);
saveErrors(request, errors);In my JSP, I iterate over the ActionMessages in the follwing way:
<table>
          <html:messages id="errors">
               <tr>
                    <td>
                         <bean:write name="errors"/>
                    </td>
               </tr>
          </html:messages>
</table>The poblem now is that in the HTML-Output, only the first Item in the Error
list appears as a literal message, whereas Struts seems to interpret the next message as a resource key:
- Literal Error 1
- ???de.Literal Error 2???
What could be the problem? Any help is appreciated!
Thanks, Ren�

Similar Messages

  • ActionMessage in struts

    hi
    ActionError was deprecated in struts 1.2.so instead of "ActionError" we are using " ActionMessage". my doubts are
    1.What actually "ActionMesages" class will do .is it's functioning is similar to
    "ActionErrors" class. anyway "ActionErrors" was not deprecated.so what is
    the need of "ActionMessages" class.
    2.to display "ActionErrors" in our jsp we use <html:errors/>.can we use this for "ActionMessages" errors or we have to use "<html:messagesPresent>".
    please clear me usage and concepts of "ActionMessage" ,"ActionMessages".

    thnks for your reply .I tried an example by using both "ActionMessages" and "ActionMessage".but the problem is "eventhough there is an error it's not displaying that error.if i used "ActionErrors" iam able to see that error.I am mentioning hte code .plz tell me where the mistake is ..
    Jsp file:---------------------
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
    <%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
    <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
    <!--
    <html:errors />
    -->
    <logic:messagesPresent>
    <html:messages id="msg" locale="fr">
    <b><bean:write name="msg" /></b><br><br><hr>
    </html:messages>
    </logic:messagesPresent>
    <html:form action="/myservice2">
    <bean:message key="app.user" />:::
    <html:text property="user"/>
    <br>
    <bean:message key="app.name" />:::
    <html:text property="name"/>
    <html:submit value="submit"/>
    </html:form>
    Action class--------------------
    package com.action;
    import com.form.Lookform;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.Globals;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;
    public class actionmess extends Action
    public ActionForward execute(ActionMapping mapping,ActionForm form,
    HttpServletRequest req,HttpServletResponse res)
    {String target;
    Lookform f=(Lookform) form;
    String user=f.getUser();
    if(user.endsWith("88"))
    target="failure";
    ActionMessages errors=new ActionMessages();
    errors.add("myerror",new ActionMessage("myerror.errors"));
    saveMessages(req,errors);
    else
    target="success";
    return mapping.findForward(target);
    validate() method in Action form returns only ActionErrors.that's why i mention "ActionMessages" in "execute()" method of Action class.
    I tried both <html:errors/> ,<html:messages> but i am unable to see errors.

  • How to display dynamic images using Struts

    I am storing the image name in bean. I want to use the <html:img> tag to display my images. How can i do that using struts.
    Something or sort..
    <html:img src=bean:write name="pageEntry" property="pageImg"/>
    Thank You

    * In your web.xml file, add the struts-html-el.tld definition from the struts\contrib\struts-el\lib directory
    * Add this tag library to your JSP page; something like:
    <%@ taglib uri="WEB-INF/struts-html-el.tld" prefix="html-el" %>* Refer to the following example:
    <html-el:img src="${pageEntry.pagePic}" />* This assumes that pageEntry is a Bean, and pagePic is a bean variable accessed by the getPagePic() method.

  • Using Logic iterate to display a arraylist in STRUts

    I m having a form bean containg a string array......
    <form-bean
    name="myDynaForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="names" type="java.lang.String[]" />
    </form- bean>
    and in my jsp , i m using .......
    <logic:iterate name="myDynaForm" property="names" id="names" >
    <tr>
    <td class="style3" align="left" width="30%" >
    <html:textarea property="names" cols="40" rows="2" size="40" indexed="true" readonly="true" />
    </td>
    </tr>
    Now this code is printing only the first element of String names.
    How can i print all the elemts of answer in my jsp

    How could you do the same thing but using only two cells?
    where the check box returns a specific value in the second.
    in this instance its for a staff registration sheet where a checkbox in (A) would return a set value in (B)
    i know this might sound simple to you guys in the know but i cant figure it out! I have been messing around trying things with the if function but still only shows me the red triangle (syntax error).
    A simple solution would be much appreciated.

  • How to   display hardcoded combo in  struts

    hi,
    I want 2 to dispaly the combo in the struts JSP which has following values
    select frequency
    year
    month
    date
    week..
    in case of simple JSP i was using like this.......
    <tr id="trDaysAfter" style="visibility:hidden; position:absolute">
         <td>Contact After:</td>
    <td><input name="txtDaysAfter" id="txtDaysAfter" type="text" size="4" value="1">
                             <select name="cmbFreq" id="cmbFreq" onChange="UpdateEndDate()">
                             <option>Selcect Frequency</option>
                             <option>Day(s)</option>
    <option>Weeks</option>
                             <option >Month(s)</option>
                             <option>Year(s)</option>
                             </select>

    Your problem seems to be more related to JavaScript than Struts.

  • Displaying Success/failurre messages in a struts landing page.

    Hi,
    I am selecting some values from a landing page, going to add/update page andthen submitting the data from add/update.
    After that the control comes to the landing page and I am displaying the message " successfully edited" in the landing page.
    Now the problem is if I come to landing page from any other page after this operation, the old message is still retained.
    how to overcome this?
    I am writing the messgaes to the session and retrieving it in the JSP page(Struts).
    Thanks,
    Dommu

    domstom wrote:
    Hi,
    I am selecting some values from a landing page, going to add/update page andthen submitting the data from add/update.
    After that the control comes to the landing page and I am displaying the message " successfully edited" in the landing page.
    Now the problem is if I come to landing page from any other page after this operation, the old message is still retained.
    how to overcome this?
    I am writing the messgaes to the session and retrieving it in the JSP page(Struts).
    Thanks,
    DommuWell if i were you i'd have define and ActionError object and would have have added respective status message under respective action method and could have forwaded it to the respective landing View and render it accordingly using <html:errors/> tag.
    or to put it in simple in struts 1.3 i'd have used the below methods.
    [http://struts.apache.org/1.x/struts-core/apidocs/org/apache/struts/action/Action.html#addErrors(javax.servlet.http.HttpServletRequest,%20org.apache.struts.action.ActionMessages)]
    [http://struts.apache.org/1.x/struts-core/apidocs/org/apache/struts/action/Action.html#addMessages(javax.servlet.http.HttpServletRequest,%20org.apache.struts.action.ActionMessages)]
    And i'd advice you to go through Best Practices which we can follow at the time of Application Devolopment using struts-1.2 framework in front-controller tier.
    [http://www.ibm.com/developerworks/web/library/wa-struts/]
    Hope that might help :)
    REGARDS,
    RaHuL

  • How to retrieve values from the struts DAO to Struts JSP

    Hi friends,
    I have one question. i want to display values in the struts jsp file from the struts DAO class. can anyone tell how do it.
    Appreciated for your help.
    Thanks
    G1 :)

    Hi Santosh,
    Thanks for your prompt reply.
    Actually, my problem is i want to display complete rows from the DAO to JSP page. I'm displaying all the rows in the DAO from DB.
    But i dont know how to retrieve all these data from DAO. Can i take arraylist.??
    DAO:
    ------------     public Customers getData(Customers customers){ // Reading data from DB
         //ArrayList list = null ;
         try
              Connection conn = getSQLConnection();
              Statement statement = conn.createStatement();
              String qry = "select * from register";
              ResultSet resultSet = null;
              PreparedStatement pstat = conn.prepareStatement(qry);
              // pstat.setString(1, customers.getFname());
              resultSet = pstat.executeQuery();
    //Print the data to the console
    while(resultSet.next()){
              String fnam = resultSet.getString(1);
              String lnam = resultSet.getString(2);
              String gen = resultSet.getString(3);
              String addres = resultSet.getString(4);
              String cit = resultSet.getString(5);
              String zip = resultSet.getString(6);
              String county = resultSet.getString(7);
              String emal = resultSet.getString(8);
              System.out.println("First name:"+fnam);
              System.out.println("Last name:"+lnam);
              System.out.println("Address:"+addres);
              customers.setFname(fnam);
              customers.setLname(lnam);
              customers.setGender(gen);
              customers.setAddress(addres);
              customers.setCity(cit);
              customers.setZipcode(zip);
              customers.setCountry(county);
              customers.setEmail(emal);
                   statement.close();
                   conn.close();
              }catch(Exception e1){
                   e1.printStackTrace();
              return customers;
    Bean:
    I have specified in this line in Bean:
    request.getSession().setAttribute("customers", customers);
    But in JSP. how will i populate all these data. Pls..send some code.
    I'm sorry this is just practicals. i'm not doin any real time project. that;s why i have placed all these code.
    Thanks for your patience for resolving my problems.
    Thanks
    G1

  • How to resolve Warning? -- in Struts

    Hi all,
    I am doing a mini project in STRUTS.
    All the code i did so far is fine and working fine.
    Now i am trying to add additional functionalities in login section in my project. To reflect the errors in the same Jsp file
    I had imported both
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    both classes..
    I am getting the warning --- "Warning -[ deprication ]org.apache.struts.action.ActionError in org.apache.struts.action has been depricated "
    Please le me know how to solve this one.
    Thanks,
    oreh

    Dont worry on the warnings. I was getting the same as well and the code still works. But its better to handle warnings for deprecations.
    Ideally ...instead of using ActionErrors its required to use another class i.e. ActionMessages in struts 1.2
    Use add("variable",ActionMessage) instead of add("variable",ActionError)
    Also in your Action form if you are using the validate method then change the following ...
    public ActionErrors validate(ActionMapping mapping,
                   HttpServletRequest request) to
    public ActionMessages validate(ActionMapping mapping,
                   HttpServletRequest request) Cheers
    -Rohit
    I havent swicthed over to the ActionMessages yet but it seems that html:errors tag has been deprecated in favour of html:messages. Check it out if this works well .
    Message was edited by:
    RohitKumar

  • Display has become unglued from top cover!

    About a month ago I noticed a slight misalignment with my cover when I closed it, and upon further inspection I discovered that the black plastic covering of the hinge was popping out slightly. After researching the problem via internet and discovering that many people had similar hinge problems, I (wrongfully) decided that I could wait for servicing until after university was over.
    Well, only about a week ago, after casual dorm usage (not using it while traveling) I closed my computer lid only to discover that there was literally no resistance in the hinge as it closed, and that the problem stemmed from the hinge area of my display literally becoming unglued from the cover. I now cannot close my computer for fear of breaking the screen any further, and I was just wondering about the serviceability of this problem and what I can do to resolve this issue as soon as possible.
    Thanks!

    Take it to an Apple store or AASP.

  • Problem with control hints and Struts tags

    hi all. i'm using jdev 10.1.2 and JSP's. I was trying to set the format mask for a couple of number fields and ran into some trouble because; "JSP 1.2 prevents control hints from being used to set input element's display properties in a Struts input form". Has anyone found a way around this.
    thanks

    in your code, are you using the name attribute?
    that's required:
    http://e-docs.bea.com/wlp/docs70/jsp/navigat.htm#999781
    there are examples of this tag in use...
    c:/bea/weblogic700/samples/portal/sampleportalDomain/beaApps/sampleportal/sampleportal/registration/new_user.jsp
    -tanya
    "Sai S Prasad" <[email protected]> wrote:
    >
    Hi,
    I am trying to populate a validatedForm text filed like this:
    <webflow:text value='<%= invoiceNumber %>' />
    I tried single and double quotes and I can't get it to work. The page
    always has
    blank value for this text field. Any suggestions are welcome. Thanks.

  • Display special characters

    Hi,
    i'm displaying usernames in our application, but i'm not sure
    how to display
    special characters correctly.
    When using the labels htmltext property, it only recognized
    html style tags, but
    no html encoded special character like &uuml; for the
    german character ü.
    The encode string is simply displayed literally: &uuml;
    Anyone knows how to display those special characters
    correctly ?

    Try one of the NSString "stringByReplacingPercentEscapesUsingEncoding" methods.

  • 15" MBP display scrambles (with and without 2nd mnitor)

    my macbook display goes berserk within a few minutes of turning it on. the display literally scrambles and looks like white noise, like an old black and white movie that's fallen off the reel. it looks like this:
    this problem happens every time, within 20 minutes of restarting the computer (which gets rid of the problem) when my MB is hooked up to a another monitor. there is no rhyme or reason for the scrambling, and i'm not doing the same action every time. interestingly, while the display on the macbook is scrambled, the computer works, and the second monitor remains clear.
    when my MB is on its own, the display scrambling occurs infrequently (once every couple of days, more so lately) but requires a restart to "fix" it.
    HELP! i keep losing files and having to reboot by holding down the power button as i can't see program windows to properly close them...

    so i just called my macbook dealer and they said it was proabably a faulty logic board. my warranty is expired and it's a $1000 fix. is there a way to get a logicboard used? i'm so crushed by this fault that showed up AFTER my warranty expired. i can't afford to fix this and the only alterntive seems to be to buy a new macbook...apple, you are SUCKING right now!

  • Displaying output to jsp

    I am trying to display userList from my struts action to jsp page,what's the code to do it using java beans or something simple?
    part code:
    action class
    public ArrayList userList = new ArrayList();
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) throws Exception {
    //get connection from database
    javax.sql.DataSource dataSource;
    java.sql.Connection myConnection = null;
    // Here the method that connects to the datasource is called:
    dataSource = getDataSource(request);
    myConnection = dataSource.getConnection();
    UserDAO dao = DAOFactory.createUserDAO(myConnection);
    userList = dao.getUser();
    HttpSession session = request.getSession();
    // extract data
    if(userList !=null){
    return mapping.findForward("success");
    }else{
    return mapping.findForward("fail");
    }

    Check java.lang.Runtime API.

  • Thunderbolt display crack

    I was unplugging my laptop from my Thunderbolt Display, literally getting ready to put it in its box to return it, and the laptop slid to the side of its elevated platform and bumped the side of the screen. It cracked the lower corner of the screen a very small bit on the outer edge of the bezel. its less than 1/4" and doesn't effect the display at all but since my laptops thunderbolt port doesn't work the display is useless to me unless someone has a solution to using it with a pc. I'm just curious what my options are. I just purchased it last week

    Cannot help you with a use for the display but the glass screen is held on with magnets so easy to change out but not sure what the cost would be.  I have seen some defective units on ebay for parts.

  • How to include HTML tags in a success message?

    I have seen a few posts on this topic in the past, but have not seen a definitive response...apologies if this has been answered.
    I would like to have a dynamic process success message that includes some HTML tags in it - in this case an anchor tag that can jump the user back to the object he/she just edited.
    So, I build up a dynamic success message in a page variable - say P10_SUCCESS_MSG - and set the Process Success Message field in the relevant Process to &P10_SUCCESS_MSG.
    The problem is that when the page template substitutes in my message for #SUCCESS_MESSAGE# it looks like it also escapes any HTML tags, so the markup gets displayed literally on the page.
    Is there any recommended way to override or get around this behavior?
    Many thanks,
    Bill

    I just noticed that it looks like the success message is passed around on the URL - when I look at my URL after a successful form process, I see &success_msg=BIG_UGLY_ESCAPED_SUCCESS_MSG_HERE embedded in the URL. If this is the case, I can see why - technically - it ends up getting escaped. Looks like I may have to figure out my own hack for success message processing - maybe some weird post-processing of a placeholder success token that I replace in a page 0 process or something...

Maybe you are looking for

  • Can we place Analog in Read(AI-RE​AD) Vi inside the while loop for high sample rate like 22ks/s?

    I am using E-series Card for data acquisition.My requirement is to sample the channel, and check the 10 samples for certain condition.both at a time.What should be done can we place the AI-READ vi inside for or while loop for this purpose?

  • WLS 10.3 - Self Registration with External LDAP Fails (somewhat)

    I have a WLS 10.3.5 instance with WebCenter Spaces. I've added an OpenLDAP provider to the security realm, set the OpenLDAP provider and the default authenticator to "sufficient", and reordered the providers in the console to list the OpenLDAP provid

  • Control record of Idoc

    Hi Experts, I need to change the partner number in the control record of IDOC. Due to this it was getting posted wrongly at status 56 "Idoc with errors added". I took a single idoc and manully changed via WE09 and reposted tho BD87.But the think is I

  • Any screen problems or kernel panics on the new 2011 mac air? Help!

    I want to buy a macbook air but i now that the old one (2010 late) has some problems - screen flickering, kernel panics and eventually death. I want the new ait but also i want a computer to work fine, not with problems. Thanks guys.

  • Error while deploying DCs

    Hi When i deploy and run my application having DCs, the following error occurs: java.lang.UnsupportedClassVersionError: com/bp/ngl/gen/simplify/wdp/InternalSimplifyInterfaceComp (Unsupported major.minor version 49.0)      at java.lang.ClassLoader.def