Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

handling errors vs. warnings in Struts 1.38

Chuck Emmons
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am writing an application that requires erroneous user input to be a "hard error" for user class A, but only a warning for user class B.

I have searched high and low for how to handle this, and came across the following "best practices" below.

1. To display the error messages of different categories, define these categories such as FATAL, ERROR, WARNING, or INFO, in an interface.

2. In the Action or form-bean class, you can then use the following:
  • errors.add("fatal", new ActionError("....")); or
  • errors.add("error", new ActionError("....")); or
  • errors.add("warning", new ActionError("....")); or
  • errors.add("information", new ActionError("...."));
  • saveErrors(request,errors);

  • 3. To display them according to those categories, use the following code:

    I am assuming that the interface mentioned above would be an interface to the ActionMessages class and that the category definitions would just be static variables in the interface. Is this the case? I need to have a way of determining if the collection contains actual errors at submittal to handle the "hard errors" or just display the warnings.

    Any advise would be greatly appreciated.

    David Newton
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Anything recommending defining constants in an interface should probably be considered outdated, at least in terms of that.

    As far as determining what the collection contains--it seems like you already are, with the messagePresent tag, no? I'm a little confused as to what the actual question is.
    Evil is afoot. But this tiny ad is just an ad:
    the new thread boost feature brings a LOT of attention to your favorite threads
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!