Re: Validation :: best practice?

2005-09-09 Thread Michael Jouravlev
On 9/9/05, emre akbas <[EMAIL PROTECTED]> wrote:
> Hi,
> I want to know what the state-of-the-art practices about Struts validation
> are.

Try these:
  https://strutslive.dev.java.net
  https://formdef.dev.java.net

> It is well-known that there are some problems in automatic validation.
> Here is a good article:
> http://www.reumann.net/struts/articles/request_lists.jsp Are the ideas in
> this article obsolete?

No more obsolete than Struts itself. Anyway, because I try to keep all
action-related stuff in the ActionForm, I never encountered the issue
of losing request-scoped objects. It seems a little strange to me,
that request-scoped objects are lost on forward, which happens on the
server.

> As far as I understand, the best practice is calling the validate() method
> manually. This requires that we write ... validate="false" ... in the
> action-mapping definition. However, if we do this, we cannot use javascript
> (client-size) validation. I want to use javascript validation. What are the
> possible solutions?

Struts cannot decide whether the tags should or should not generate
client-side validation javascript in the JSP pages belonging to an
action, simply because Struts does not have the notion of a JSP page
"belonging" to a certain action class. Actions and pages are
interlaced in a chain fashion and generally you don't know which
action the data from a page will be submitted to.

Therefore client-side validation is set separately with
 tag on JSP page, while automatic server-side
validation is set with validate="true" in the action mapping
definition.

Michael.

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



Re: Validation :: best practice?

2005-09-09 Thread Rick Reumann

emre akbas wrote the following on 9/9/2005 10:12 AM:
 ,
I want to know what the state-of-the-art practices about Struts validation 
are. It is well-known that there are some problems in automatic validation. 
Here is a good article: 
http://www.reumann.net/struts/articles/request_lists.jsp Are the ideas in 
this article obsolete? 


I don't think they are obsolete. I still find it easier to call validate 
manually. (By the way, in that article, I mention a technique that I 
really don't use myself.. I don't even bother calling the form's 
validate method. I actually provide my own validate() method in my 
Action that validates what I want. Both work ok though and since many 
already have a validate method in their ActionForm, I used that as the 
example for the lesson.)


As far as I understand, the best practice is calling the validate() method 
manually. 


If you have session based forms or you do not need to re-display 
non-ActionForm objects back on the page if validation fails, the 
standard validation framework is 'ok', but I still like to do do things 
one consistent way so doing my validation in my actions works for me. I 
will almost bet there will be a time when you'll run into some headaches 
trying to use the validation frameworks as it stands. (Validation in 
struts is not one of Struts' strong points unfortunately. It's one of 
the number one headaches for beginning struts users.)


This requires that we write ... validate="false" ... in the 
action-mapping definition. 


If I remember correctly, if you leave off the validate="false" it 
defaults to false. You just need to set it to true if you want 
validation, but I could be wrong there.. it's been a while:)


However, if we do this, we cannot use javascript 
(client-size) validation. I want to use javascript validation. What are the 
possible solutions? 


I never had too much luck with the client side validation stuff and I 
only use it in *very* limited circumstances, since I like validating on 
the server side.  The javascript validation with the validator seemed 
more of a headache then it was worth when I first started trying it out 
(I'm sure it's improved a lot since then, so it might work nicely for 
you). For client side validation I just write my own and don't rely on 
the validator stuff to handle it. Since I rarely validate on the client 
it's not much of an issue for me.


--
Rick

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



Re: Validation :: best practice?

2005-09-09 Thread Niall Pemberton
I think you're assertion is incorrect. including the  tag
on a page will generate all the javascript validations for a form - they get
"invoked" by you putting some javascript in the 's onsubmit
event - nothing to do with the validate setting in the struts config. All
the validate=false setting controls is server side validation.

Niall

- Original Message - 
From: "emre akbas" <[EMAIL PROTECTED]>
Sent: Friday, September 09, 2005 3:12 PM

> This requires that we write ... validate="false" ... in the
> action-mapping definition. However, if we do this, we cannot use
javascript
> (client-size) validation. I want to use javascript validation



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