You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Jens v.P." <de...@jevopi.de> on 2003/07/23 15:46:12 UTC
Has anybody extended the validator framework?
Hello,
I'm wondering if anybody has already extended the validator framework
- to use it in the business layer instead of the controller layer
- supporting dynamically loaded/created forms
Validating user input is no special struts or web application
requirement. In my case, all applications are web applications, but
I've got different "applications" based on the same business data (the
layout differs). Also, I've got a lot of questionnaires which are going
to be implemented as forms. Thus I want to define the validation
together with the questionnaire aka form.
The validator framework is part of the controller. IMHO in case of
questionnaires this is the "wrong" tier - a questionnaire is a business
object, and validating the user input must be defined there. Of course,
the same validation rules also apply for the validation of the form
input. In other words, the questionnaire is the model for the form -
the form is the view.
So, what I'm looking for is a way to use the validator framework for
defining my (business) questionnaires. The questionnaire then "works"
as a model providing the validation rules to the view /or controller.
I've read (in Chuck Cavaness' book on struts) how to use the validator
framework outside struts - but this is not really the point: I want to
use it outside and inside at the same time - and (to make it a little
bit more interesting) I need also some extensions, e.g. defining
question blocks, "super-properties", filters.
I've found some questions here before on that or similar topics, so
maybe the problem was solved before? Otherwise I'll try to solve this
problem - in this case some hints may help a lot :)
Jens
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Has anybody extended the validator framework?
Posted by Derek Chen-Becker <db...@cpicorp.com>.
Teaches me to skim the docs. I missed the part in the Validator dev docs
where it says it can generate javascript... You might be able to get
somewhere by overriding the
org.apache.commons.validator.ValidatorResources that's set as an
application scope attribute. I just skimmed through it but that looks
like where the validator gets its info from.
Derek
Jens v.P. wrote:
> Hi,
>
> thanks Derek, thanks Chuck.
>
> Am Mittwoch, 23.07.03 um 17:24 Uhr schrieb Derek Chen-Becker:
>
> [..]
>
>> I hadn't thought of client-side validation, but that's kind of tricky
>
> [..]
>
>> Or am I misunderstanding what you mean by "client-side"?
>
>
> No, that's what I meant. But: the validator framework already solves
> this tricky problem :). It seems that the only problem I have is that
> the validator framework requires static xml files for configuration -
> and I need dynamically configured validation. Just as Chuck Canning wrote:
>
> "To summarize, I suggest that you dynamically build what normally
> would be defined in validation.xml in struts1.1."
>
> I need a way to replace validation.xml by dynamic Java calls. I guess
> that this is not too tricky and I was only wondering if somebody has
> already done this.
>
> Jens
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
----------------------------------------------------------------------
Derek Chen-Becker
Senior Network Engineer
CPI Corp, Inc.
1706 Washington Ave
St. Louis, MO 63103
Phone: 314-231-1575 x6014
Fax: 314-613-6724
dbecker@cpicorp.com
PGP Key available from public key servers
Fingerprint: 1C34 D81E D8A0 641D 6C8C E952 3B15 693F 9184 BC58
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Has anybody extended the validator framework?
Posted by "Jens v.P." <de...@jevopi.de>.
Hi,
thanks Derek, thanks Chuck.
Am Mittwoch, 23.07.03 um 17:24 Uhr schrieb Derek Chen-Becker:
[..]
> I hadn't thought of client-side validation, but that's kind of tricky
[..]
> Or am I misunderstanding what you mean by "client-side"?
No, that's what I meant. But: the validator framework already solves
this tricky problem :). It seems that the only problem I have is that
the validator framework requires static xml files for configuration -
and I need dynamically configured validation. Just as Chuck Canning
wrote:
"To summarize, I suggest that you dynamically build what normally
would be defined in validation.xml in struts1.1."
I need a way to replace validation.xml by dynamic Java calls. I guess
that this is not too tricky and I was only wondering if somebody has
already done this.
Jens
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Has anybody extended the validator framework?
Posted by Derek Chen-Becker <db...@cpicorp.com>.
That was what I was thinking of. I hadn't thought of client-side
validation, but that's kind of tricky unless you want to extend the form
tags and Form classes. If you wanted to automate client-side validation
you would have to extend the ActionForm class so that you can provide
information about how to validate its fields, and then extend the
html:form-related tags to use that info to create javascript or
something else to perform the validation. This would be fairly complex
unless you're talking about trivial validation (field not empty, numeric
value, etc.). Or am I misunderstanding what you mean by "client-side"?
Derek
Jens v.P. wrote:
> Hi,
>
> Am Mittwoch, 23.07.03 um 16:24 Uhr schrieb Derek Chen-Becker:
>
>> Since the questionnaire is the model for the form, couldn't you just
>> encapsulate a real questionnaire business object within an ActionForm?
>> It adds a layer, but since ActionForms are objects and not interfaces
>> I don't see an easier way than delegation.
>>
>
> I'm not sure I understand that. Do you mean to use the validator
> "outside" struts (in the business layer) and delegate all validations in
> the form to the business object? Like this:
>
> MyForm extends ActionForm {
> ..
> public ActionErrors validate(..) {
> ...
> Questionnaire->validate();
> ...
> }
> }
>
> That was my first idea, too. But in this case I don't know how to use
> client side validation (and that's a really nice feature). And it still
> doesn't solve the problem of dynamically created questionnaires/forms.
>
> I'm thinking about a way to extend/modify the validator for supporting
> "runtime configuration". I hope that this is not too complicate - I
> guess that I only have to exchange the digester creation by a runtime
> configuration. Or by simply "extending" the digester for creating my own
> "business" classes, adding some features which I require, and add the
> ability to the business classes (or add a layer between with this
> ability) to generate the validator framework classes on the fly, based
> on the extended definition.
>
>
>
> Jens
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
----------------------------------------------------------------------
Derek Chen-Becker
Senior Network Engineer
CPI Corp, Inc.
1706 Washington Ave
St. Louis, MO 63103
Phone: 314-231-1575 x6014
Fax: 314-613-6724
dbecker@cpicorp.com
PGP Key available from public key servers
Fingerprint: 1C34 D81E D8A0 641D 6C8C E952 3B15 693F 9184 BC58
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Has anybody extended the validator framework?
Posted by "Jens v.P." <de...@jevopi.de>.
Hi,
Am Mittwoch, 23.07.03 um 16:24 Uhr schrieb Derek Chen-Becker:
> Since the questionnaire is the model for the form, couldn't you just
> encapsulate a real questionnaire business object within an ActionForm?
> It adds a layer, but since ActionForms are objects and not interfaces
> I don't see an easier way than delegation.
>
I'm not sure I understand that. Do you mean to use the validator
"outside" struts (in the business layer) and delegate all validations
in the form to the business object? Like this:
MyForm extends ActionForm {
..
public ActionErrors validate(..) {
...
Questionnaire->validate();
...
}
}
That was my first idea, too. But in this case I don't know how to use
client side validation (and that's a really nice feature). And it still
doesn't solve the problem of dynamically created questionnaires/forms.
I'm thinking about a way to extend/modify the validator for supporting
"runtime configuration". I hope that this is not too complicate - I
guess that I only have to exchange the digester creation by a runtime
configuration. Or by simply "extending" the digester for creating my
own "business" classes, adding some features which I require, and add
the ability to the business classes (or add a layer between with this
ability) to generate the validator framework classes on the fly, based
on the extended definition.
Jens
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Has anybody extended the validator framework?
Posted by Derek Chen-Becker <db...@cpicorp.com>.
Since the questionnaire is the model for the form, couldn't you just
encapsulate a real questionnaire business object within an ActionForm?
It adds a layer, but since ActionForms are objects and not interfaces I
don't see an easier way than delegation.
Derek
Jens v.P. wrote:
> Hello,
>
> I'm wondering if anybody has already extended the validator framework
> - to use it in the business layer instead of the controller layer
> - supporting dynamically loaded/created forms
>
> Validating user input is no special struts or web application
> requirement. In my case, all applications are web applications, but I've
> got different "applications" based on the same business data (the layout
> differs). Also, I've got a lot of questionnaires which are going to be
> implemented as forms. Thus I want to define the validation together with
> the questionnaire aka form.
>
> The validator framework is part of the controller. IMHO in case of
> questionnaires this is the "wrong" tier - a questionnaire is a business
> object, and validating the user input must be defined there. Of course,
> the same validation rules also apply for the validation of the form
> input. In other words, the questionnaire is the model for the form - the
> form is the view.
>
> So, what I'm looking for is a way to use the validator framework for
> defining my (business) questionnaires. The questionnaire then "works" as
> a model providing the validation rules to the view /or controller.
>
> I've read (in Chuck Cavaness' book on struts) how to use the validator
> framework outside struts - but this is not really the point: I want to
> use it outside and inside at the same time - and (to make it a little
> bit more interesting) I need also some extensions, e.g. defining
> question blocks, "super-properties", filters.
>
> I've found some questions here before on that or similar topics, so
> maybe the problem was solved before? Otherwise I'll try to solve this
> problem - in this case some hints may help a lot :)
>
> Jens
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
----------------------------------------------------------------------
Derek Chen-Becker
Senior Network Engineer
CPI Corp, Inc.
1706 Washington Ave
St. Louis, MO 63103
Phone: 314-231-1575 x6014
Fax: 314-613-6724
dbecker@cpicorp.com
PGP Key available from public key servers
Fingerprint: 1C34 D81E D8A0 641D 6C8C E952 3B15 693F 9184 BC58
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org