You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurent Duperval <ld...@yahoo.com> on 2004/10/18 20:19:03 UTC

Extending DynaValidatorActionForm... or using something else?

HI,

We've created a bunch of forms to allow users to create new object in 
our database. All the forms have a "name" property in them, and 
depending on the object, there are other properties. Most of our 
validation is just a simple "required".

However, we have a business rule which states that two objects o f the 
same type cannot have the same name. In order to check this, we have to 
query the database.

In order to implement this, I was wondering if it was better to try and 
extend the DynaValidatorActionForm, or whether puttin git in the action 
is the best way to do it? We always want the same behaviour for all our 
objects: if the name exists already, send the user back to the entry 
page with an error messagae that asks to use a different name.

I'm sure others have done something similar. What approaches have you taken?

Thanks,

L


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Extending DynaValidatorActionForm... or using something else?

Posted by Laurent Duperval <ld...@yahoo.com>.
Eddie Bush wrote:
> Application-specific exceptions are one of the least used and most 
> useful tools.  That's exactly how I'd go about doing it, and I dare say 
> it's the right way.
> 

Indeed. One thing I've found with this approcah: if I don't put all the 
mandatory data in the form, I get an error message (as expected) and my 
for is reloaded -- with all the previous data removed.

Currently, to circumvent this problem, we have to take that data from 
the form and store it in the session. It's all done inside the action 
and involves a fair amount of gymnastics (defining special request 
parameters, dealing with them in the action, etc).

Is there a simpler way? Is there a way to tell struts to reload the 
*modified* data tha was entered in the form without jumping through hoops?

For example, say you have a Person form which has 10 fields, of which 
three (last name, first name and sex) are mandatory. The way we have 
things set up, if we enter data for all the fields and miss one of the 
mandatory fields, the form is redisplayed and everything ise removed. 
What I'd like is for the form to be redisplayed, using the data I 
entered originally, or the modified data.

It might be important to know that we use the same form to add and to 
modify data. We have two different actions (/edit* and /add*) that map 
to the same page. The page will behave differently, depending on whether 
  we are adding or modifying data.

Thanks,

L


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Extending DynaValidatorActionForm... or using something else?

Posted by Eddie Bush <ea...@swbell.net>.
Application-specific exceptions are one of the least used and most useful 
tools.  That's exactly how I'd go about doing it, and I dare say it's the 
right way.

----- Original Message ----- 
From: "Laurent Duperval" <ld...@yahoo.com>
To: <us...@struts.apache.org>
Sent: Monday, October 18, 2004 1:42 PM
Subject: Re: Extending DynaValidatorActionForm... or using something else?


> Laurent Duperval wrote:
>> I'm sure others have done something similar. What approaches have you 
>> taken?
>>
>
> Well, shortly after posting this, I remembered the <exception> tag could 
> be added in an action. By defining a specific exception for the errors I'm 
> trackin and sending them back to the container, this seems to fit the 
> bill. There's still a couple of minor issues, but I think this might be 
> sufficient.
>
> L 



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0442-3, 10/15/2004
Tested on: 10/18/2004 7:06:26 PM
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Extending DynaValidatorActionForm... or using something else?

Posted by Laurent Duperval <ld...@yahoo.com>.
Laurent Duperval wrote:
> I'm sure others have done something similar. What approaches have you 
> taken?
> 

Well, shortly after posting this, I remembered the <exception> tag could 
be added in an action. By defining a specific exception for the errors 
I'm trackin and sending them back to the container, this seems to fit 
the bill. There's still a couple of minor issues, but I think this might 
be sufficient.

L


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org