Struts errors/messages

Discussion in 'Java' started by Ryan Stewart, Feb 29, 2004.

  1. Ryan Stewart

    Ryan Stewart Guest

    Another Struts question... If I have several messages/errors that I want to
    display, using html:messages or html:errors, can I specify to display one
    message in a particular spot and all the rest somewhere else? When I try
    that, I get the one message where I want it, but in the "everything else"
    area, the error shows up again. Is there a way to have it removed from the
    ActionMessages collection when it is used or something like that?
     
    Ryan Stewart, Feb 29, 2004
    #1
    1. Advertising

  2. Ryan Stewart

    Sudsy Guest

    Ryan Stewart wrote:
    > Another Struts question... If I have several messages/errors that I want to
    > display, using html:messages or html:errors, can I specify to display one
    > message in a particular spot and all the rest somewhere else? When I try
    > that, I get the one message where I want it, but in the "everything else"
    > area, the error shows up again. Is there a way to have it removed from the
    > ActionMessages collection when it is used or something like that?


    What I do is something like this:

    ActionErrors errs = new ActionErrors();
    // for field-specific error
    errs.add( "fieldName", new ActionError( ... ) );
    // for global error
    errs.add( ActionErrors.GLOBAL_ERROR, new ActionError( ... ) );

    and in the JSP I do this to display global errors:

    <html:errors property="org.apache.struts.action.GLOBAL_ERROR">

    For the field-specific errors, I use this:

    <html:errors property="fieldName">

    I also did a search of the archives and found this same information,
    courtesy of the same poster (me). Try it yourself next time... ;-)
     
    Sudsy, Feb 29, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,033
    Mark Goldin
    Jan 17, 2004
  2. Klaus
    Replies:
    0
    Views:
    3,871
    Klaus
    Jul 2, 2003
  3. PC Leung
    Replies:
    4
    Views:
    9,623
    greenleaf81
    Oct 22, 2008
  4. ctyberg
    Replies:
    0
    Views:
    384
    ctyberg
    Dec 15, 2004
  5. Konrad Billewicz

    Struts - nested messages

    Konrad Billewicz, Jul 18, 2005, in forum: Java
    Replies:
    2
    Views:
    568
    Konrad Billewicz
    Jul 19, 2005
Loading...

Share This Page