You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ad...@cfsms.nhs.uk on 2004/06/03 14:17:25 UTC
Bug in Forms v1, 2 & 3 using Cocoon v2.1.5, flow, javascript validation and
debugging
Hi,
I have a form that uses javascript to perform validation. I've
implemented the validator using <fd:javascript> in the form definition.
Unfortunately, when I enable flow debug I get a NullPointerException on
loading the form definition:
Form (resource://org/apache/cocoon/forms/flow/javascript/v3/Form.js, Line
54): java.lang.NullPointerException
If disable debug then the problem is solved.
I had noticed this problem previously and implemented a work-around with
flow level validators so as not to have to put the Javascript in the form
definition. Unfortunately I have just upgraded from 2.1.5-dev to 2.1.5
final and to my suprise I discover that support for adding custom flow
level validators has been removed so my work-around for this problem no
longer works either! (By the way, this also means that the
http://localhost:8888/samples/blocks/forms/form1.flow sample no longer
works as it should - the javascript validation rule for price per liter of
diesel is not enforced).
Please can someone help out with this?
Thanks in advance,
Adrian
Re: Bug in Forms v1, 2 & 3 using Cocoon v2.1.5, flow, javascript
validation and debugging
Posted by Joerg Heinicke <jo...@gmx.de>.
On 08.06.2004 23:20, Yatin Shah wrote:
> My requirement:
> Perform business level validation to ensure the entered data are valid
> before notifying the user that
> their form request is accepted and refreshing the web page with
> acceptance message.
> [business level: requires access to external database for checking valid
> values.]
>
> Pre 2.1.5 solution:
> Define a javascript function, a part of the flow script, to do business
> validation processing and associate this function with the form using:
> A. "I used fd:javascript though where only external validation functions
> are called. So I determine how a field has to be validated in the form
> definition, but the validation itself is scripted in external js
> files."
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108639582110249&w=2
> Joerg, can you give more details! Is it possible to access flow
> variables from your external js file?
I have a file validate.js that has some validateXYZ() functions in it.
validate.js is added to the sitemap like any other flowscript js file.
In the form definition I have:
<fd:field>
<fd:validation>
<fd:javascript>
return validateXYZ(widget);
</fd:javascript>
</fd:validation>
</fd:field>
> B. "On each widget, you can add validators using the
> Widget.addValidator(...) method. The argument is an implementation of
> WidgetValidator. See the javadoc of that interface for more details on
> what an implementation of a WidgetValidator is supposed to do."
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108401608717385&w=2
> This seems to be for individual widget level validation support. How can
> this be used for the form level validation? A sample code will be very
> helpful.
Bruno explained some more details here:
http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108555680116244&w=4.
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Bug in Forms v1, 2 & 3 using Cocoon v2.1.5, flow, javascript
validation and debugging
Posted by Yatin Shah <no...@kripa.com>.
I also have a similar problem.
I upgraded to 2.1.5, and now my javascript(flow) based forms(Cocoon
Forms - woody) validation is no longer supported.
I searched the mail list but could not really find a suitable solution.
My requirement:
Perform business level validation to ensure the entered data are valid
before notifying the user that
their form request is accepted and refreshing the web page with
acceptance message.
[business level: requires access to external database for checking valid
values.]
Pre 2.1.5 solution:
Define a javascript function, a part of the flow script, to do business
validation processing and
associate this function with the form using:
val_method = Validate_signin;
formMgr = new Form(form_definition);
formMgr.validator = val_method; <=================== SET
Validation Method =======
formMgr.load(model);
var kont = formMgr.showForm("XMLcollector", { "flowRequest":
flowRequest, "collector":"cocoonform", collectorData":collectorData,
"model": model});
...
...
function Validate_signin(formMgr, bizdata) {
//
//Within function I can access any widgets and my flow variables
//to validate my form.
//I can also access the database data for my validation.
}
From the mailing list I gather following hints for 2.1.5. Are there any
other options? Any suggestions/code is welcome.
A. "I used fd:javascript though where only external validation functions
are called. So I determine how a field has to be validated in the form
definition, but the validation itself is scripted in external js
files."
http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108639582110249&w=2
Joerg, can you give more details! Is it possible to access flow
variables from your external js file?
B. "On each widget, you can add validators using the
Widget.addValidator(...) method. The argument is an implementation of
WidgetValidator. See the javadoc of that interface for more details on
what an implementation of a WidgetValidator is supposed to do."
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108401608717385&w=2
This seems to be for individual widget level validation support. How can
this be used for the form level validation? A sample code will be very
helpful.
TIA.
Yatin
>
> The flow level validation hack was replaced in favor of widget
> validators:
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108555680116244&w=4
> I used fd:javascript though where only external validation functions
> are called. So I determine how a field has to be validated in the form
> definition, but the validation itself is scripted in external js files.
>
> Joerg
>
> ---------------------------------------------------------------------
> 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
Re: Bug in Forms v1, 2 & 3 using Cocoon v2.1.5, flow, javascript
validation and debugging
Posted by Joerg Heinicke <jo...@gmx.de>.
On 03.06.2004 14:17, Adrian.Cross@cfsms.nhs.uk wrote:
> Hi,
>
> I have a form that uses javascript to perform validation. I've
> implemented the validator using <fd:javascript> in the form definition.
> Unfortunately, when I enable flow debug I get a NullPointerException on
> loading the form definition:
>
> Form (resource://org/apache/cocoon/forms/flow/javascript/v3/Form.js, Line
> 54): java.lang.NullPointerException
>
> If disable debug then the problem is solved.
I heard of it, but I have no knowledge to fix it.
> I had noticed this problem previously and implemented a work-around with
> flow level validators so as not to have to put the Javascript in the form
> definition. Unfortunately I have just upgraded from 2.1.5-dev to 2.1.5
> final and to my suprise I discover that support for adding custom flow
> level validators has been removed so my work-around for this problem no
> longer works either! (By the way, this also means that the
> http://localhost:8888/samples/blocks/forms/form1.flow sample no longer
> works as it should - the javascript validation rule for price per liter of
> diesel is not enforced).
>
> Please can someone help out with this?
The flow level validation hack was replaced in favor of widget
validators:
http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108555680116244&w=4
I used fd:javascript though where only external validation functions are
called. So I determine how a field has to be validated in the form
definition, but the validation itself is scripted in external js files.
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org