struts wrapping exceptions mvc

C

Carse

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top