struts wrapping exceptions mvc

Discussion in 'Java' started by Carse, Feb 18, 2005.

  1. Carse

    Carse Guest

    How do you get a message back to the View layer with declarative
    exception handling in an MVC application?

    My DAOs are abstracted such that the methods throw
    DataAccessExceptions. My business layer catches these and throws
    ApplicationExceptions (as described in the book 'Pro Jakarta Struts').
    One of the exceptions I want to be displayed to the user is if they
    enter a record with a duplicate username. I'll check for this in my
    business logic and throw a DuplicateUsernameException, which extends
    ApplicationException.

    The problem is that the following action exception tag doesn't work in
    my struts-config.xml:

    <action path="/saveUser"
    type="myproj.actions.saveUserAction"
    name="userForm"
    scope="request"
    input="editUser.jsp"
    validate="true"
    <exception
    key="error.userform.duplicateusername"
    type="myproj.common.DuplicateUsernameException" />
    ....
    </action>

    It only works if I change the exception type to ApplicationException -
    which could be a variety of things!

    How do I set this up such that it can catch a
    DuplicateUsernameException yet still preserve the encapsulation of the
    business logic via ApplicationExceptions?

    Thank you in advance for your time and assistance.
    -Carse.
    Carse, Feb 18, 2005
    #1
    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. Edward A Thompson
    Replies:
    2
    Views:
    622
    Tim Jowers
    Jul 14, 2003
  2. RedGrittyBrick

    Exceptions in Threads (& MVC)

    RedGrittyBrick, Nov 8, 2007, in forum: Java
    Replies:
    3
    Views:
    383
    k.adamczyk
    Nov 8, 2007
  3. rmn190
    Replies:
    2
    Views:
    2,352
    Arne Vajhøj
    Jan 10, 2008
  4. Paulo
    Replies:
    3
    Views:
    475
    Peter Bromberg [C# MVP]
    Dec 4, 2008
  5. Crazy Cat
    Replies:
    1
    Views:
    682
    schepp
    Sep 3, 2009
Loading...

Share This Page