Sure; catch the exception in your Action, which IMO is what should happen
anyway.

This is a gray area of design for me; I am not convinced that this is
"exceptional" behavior. That aside, business-level exceptions should (IMO, of
course :) be caught by actions--*real* exceptions, like a database error,
transport-level error etc. should be caught by the framework. Business-level
exceptions are recoverable by the user, lower-level exceptions may not be.

There are an arbitrary number of other ways to handle this, the above is just
my general opinion, but even that depends on other aspects of system
architecture.

d.

--- "Jeremy JGR. Grumbach" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> Let's take the following scenario: we have a database which manage car
> models (for example Dogde Viper). The column "name" of the "car model"
> table must be unique.
> The user wants to add a "car model" in the database, thus he has an "add
> screen" containing all the fields of the "car model" and a "Save"
> button. However he has entered a model which already exists in the
> database. I check that in my business layer and return a runtime
> exception "name already exists".
> I can display it using global-exceptions, however it is forwarded to
> another page and consequently, the user must reenter all the field
> values one more time.
> To avoid that, I want to go back to the "add screen" without losing user
> inputs but with a red message "name already exists in the database" -
> exactly like the struts validation error messages.
> 
> Do you think it is possible with Struts 2? I have used that lots of time
> in Struts 1.
> 
> Thanks in advance,
> 
> Jeremy 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to