You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Olivier Billard <ob...@rennes.jouve.fr> on 2004/01/06 16:55:38 UTC

[Cocoon forms] interaction between definition validation and flow validator

Hi cocooners !

I asked a question yesterday, that is maybe not clear, so let me explain cleaner.

Cocoon forms offers 2 ways of validating a form : definition validation (with 
<wd:validation> in the form def file) and in the flow with the validator property of the 
flow form object.

And how can I combine the 2, if it's possible ? I would like to use the definition 
validation pour simple validations like required fields or min/max, and the flow 
validation in addition, for more complex things like unique values control in repeaters, 
or business actions...

My flow validator function begins with :
<code>
if (!form.getWidget().isValid()) {
     return false;
}
</code>

But even when the form seems to be valid, isValid() returns false, and I can never run 
"business validation" code after the test...

I'm using 2.1.2 version of cocoon.

Thanks,

-- 
Olivier BILLARD



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: AW: [Cocoon forms] interaction between definition validation and flow validator

Posted by Olivier Billard <ob...@rennes.jouve.fr>.
Hi Markus,

Thanks for your answer.

I also used
     form.validator = myValidator;
But I don't want to do business stuff if the basic definition validation doesn't work

I have :

function myValidator(form) {
     if (!form.getWidget().isValid()) {
         cocoon.request.setAttribute("formulaire", form.getWidget());
         return false;
     }

     -- some business stuff --
}

but when the form seems to be valid (and all required fields are present) from its 
definition validations, isValid() still returns false, and the business stuff is not executed.

My present validator code tests all fields values against the null value to see if 
definition validation passed successfully, but that's not very clean...

--
Olivier


On 06/01/2004 17:17, Markus Heussen wrote:

> Hi!
> 
> I use
> 
> form.validator = myValidator;
> 
> placed before
> 
> form.showForm("form.display");
> 
> 
> and in my validator function something like this
> 
> function myValidator(form) {
> 	var validationError = new
> Packages.org.apache.cocoon.woody.datatype.ValidationError("xxx");
> 	if (!isDate(form.getWidget("vn_geburtsdatum").getValue(),"dd.MM.yyyy")) {
> 		form.getWidget("vn_geburtsdatum").setValidationError(validationError);
> 		return false;
> 	}
> 	return true;
> }
> 
> and this works fine for me. Only if all validations (in descriptor file and
> my flow validator function) give true the form is no more redisplayed.
> 
> Regards, Markus
> 
> 
> 
> 
>>-----Ursprungliche Nachricht-----
>>Von: news Im Auftrag von Olivier Billard
>>Gesendet: Dienstag, 6. Januar 2004 16:56
>>An: users@cocoon.apache.org
>>Betreff: [Cocoon forms] interaction between definition validation and
>>flow validator
>>
>>
>>Hi cocooners !
>>
>>I asked a question yesterday, that is maybe not clear, so let me
>>explain cleaner.
>>
>>Cocoon forms offers 2 ways of validating a form : definition
>>validation (with
>><wd:validation> in the form def file) and in the flow with the
>>validator property of the
>>flow form object.
>>
>>And how can I combine the 2, if it's possible ? I would like to
>>use the definition
>>validation pour simple validations like required fields or
>>min/max, and the flow
>>validation in addition, for more complex things like unique
>>values control in repeaters,
>>or business actions...
>>
>>My flow validator function begins with :
>><code>
>>if (!form.getWidget().isValid()) {
>>     return false;
>>}
>></code>
>>
>>But even when the form seems to be valid, isValid() returns
>>false, and I can never run
>>"business validation" code after the test...
>>
>>I'm using 2.1.2 version of cocoon.
>>
>>Thanks,
>>
>>--
>>Olivier BILLARD



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Cocoon forms] interaction between definition validation and flow validator

Posted by Olivier Billard <ob...@rennes.jouve.fr>.
Hi Tim !

Thanks for your answer.
It seems that all my required fields are present, excepts a repeater (that is not required 
if such attribute is valid for a repeater) because there is no rows in.

And the isValid() returns false...
argh !

--
Olivier


On 06/01/2004 17:11, Tim Larson wrote:

> --- Olivier Billard <ob...@rennes.jouve.fr> wrote:
> 
>>Hi cocooners !
> 
> 
> Hello!
> 
> 
>>My flow validator function begins with :
>><code>
>>if (!form.getWidget().isValid()) {
>>     return false;
>>}
>></code>
>>
>>But even when the form seems to be valid, isValid() returns false, and I can never run 
>>"business validation" code after the test...
> 
> 
> Usually this is caused by the form template not including a widget which is marked
> with 'required="true"'.  Because the widget is not in the template, it is not returned
> in the form post, and thus is set to null during readFromRequest() causing the form
> (at least the visible parts that were included in the template) to look valid while
> there is actually still an invalid widget.
> 
> HTH,
> --Tim Larson



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [Cocoon forms] interaction between definition validation and flow validator

Posted by Tim Larson <ti...@yahoo.com>.
--- Olivier Billard <ob...@rennes.jouve.fr> wrote:
> Hi cocooners !

Hello!

> My flow validator function begins with :
> <code>
> if (!form.getWidget().isValid()) {
>      return false;
> }
> </code>
> 
> But even when the form seems to be valid, isValid() returns false, and I can never run 
> "business validation" code after the test...

Usually this is caused by the form template not including a widget which is marked
with 'required="true"'.  Because the widget is not in the template, it is not returned
in the form post, and thus is set to null during readFromRequest() causing the form
(at least the visible parts that were included in the template) to look valid while
there is actually still an invalid widget.

HTH,
--Tim Larson


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


AW: [Cocoon forms] interaction between definition validation and flow validator

Posted by Markus Heussen <he...@rheinland-online.com>.
Hi!

I use

form.validator = myValidator;

placed before

form.showForm("form.display");


and in my validator function something like this

function myValidator(form) {
	var validationError = new
Packages.org.apache.cocoon.woody.datatype.ValidationError("xxx");
	if (!isDate(form.getWidget("vn_geburtsdatum").getValue(),"dd.MM.yyyy")) {
		form.getWidget("vn_geburtsdatum").setValidationError(validationError);
		return false;
	}
	return true;
}

and this works fine for me. Only if all validations (in descriptor file and
my flow validator function) give true the form is no more redisplayed.

Regards, Markus



> -----Ursprungliche Nachricht-----
> Von: news Im Auftrag von Olivier Billard
> Gesendet: Dienstag, 6. Januar 2004 16:56
> An: users@cocoon.apache.org
> Betreff: [Cocoon forms] interaction between definition validation and
> flow validator
>
>
> Hi cocooners !
>
> I asked a question yesterday, that is maybe not clear, so let me
> explain cleaner.
>
> Cocoon forms offers 2 ways of validating a form : definition
> validation (with
> <wd:validation> in the form def file) and in the flow with the
> validator property of the
> flow form object.
>
> And how can I combine the 2, if it's possible ? I would like to
> use the definition
> validation pour simple validations like required fields or
> min/max, and the flow
> validation in addition, for more complex things like unique
> values control in repeaters,
> or business actions...
>
> My flow validator function begins with :
> <code>
> if (!form.getWidget().isValid()) {
>      return false;
> }
> </code>
>
> But even when the form seems to be valid, isValid() returns
> false, and I can never run
> "business validation" code after the test...
>
> I'm using 2.1.2 version of cocoon.
>
> Thanks,
>
> --
> Olivier BILLARD
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org