Thanks for the reply,

That's possible but it implies that my action knows which exceptions can
be raised from the business layer. I was thinking of a "generic" way to
do that.
In Struts 1, it was possible to link an exception to a key of the
application.properties file:
<global-exceptions>
 <exception type="NameAlreadyExistsException" 
                key="error.nameAlreadyExistsException" 
                handler="org.[...].myExceptionHandler"/>         
</global-exceptions>

And in the exception handler, an ActionError was saved using the key
value defined above ("error.nameAlreadyExistsException" ) and then the
exception handler returned "input" as default forward.

Thus I had in my page the error message saved in ActionError and all the
user fields still filled in because the forward was "input".

Not sure to be clear but that's what I hope to be able to do in Struts
2.

Jeremy

-----Original Message-----
From: Dave Newton [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 17, 2007 7:17 PM
To: Struts Users Mailing List
Subject: Re: Exception Handling keeping user input

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]


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

Reply via email to