You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by ba...@wipro.com on 2004/11/24 10:22:54 UTC

[CForms] widget validation

Hi,

I want to validate all the field widgets with their 'required '
attribute set to true.

For that I have a <fd:javascript> snippet which calls a function written
in flowscript.

Following is the snippet in my form definition file: -

  <fd:submit id="submit" action-command="submit form">
   <fd:on-action>
     <fd:javascript>
       validateRequired(event.source.parent);
    </fd:javascript>
   </fd:on-action>
 </fd:submit>

And this is what I have in my flowscript: -

function validateRequired(wid) {

  print("Calling validateRequired");
  print("get children " + wid.getChildren());
 
  var widIter = wid.getChildren();
  
  while (widIter.hasNext()) {
    var widObj = widIter.next();
   
	print("Widgets are "+ widObj.getValue() + " Is required " +
widObj.isRequired());
    
	if (widObj.isRequired && widObj.getValue() == null) {
     
      widObj.setValidationError(new
Packages.org.apache.cocoon.forms.validation.ValidationError("Please
enter a value for the required field"));
    }
 }
}

The above code throws an error as follows: -

setValidationError is not a function.

I browsed the Cocoon API. I can see that setValidation Error is a method
in the Field Class of the FormModel package.

Can anyone help me in pointing out what could be wrong in the above
code.

Cheers
Baskar



Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

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


Re: [CForms] widget validation

Posted by Scott Yeadon <sc...@anu.edu.au>.
You might want to double-check that all the widgets being processed are 
all Field widgets - perhaps there are some other widget types in the 
hierarchy?

baskar.ganesh@wipro.com wrote:

>Hi,
>
>I want to validate all the field widgets with their 'required '
>attribute set to true.
>
>For that I have a <fd:javascript> snippet which calls a function written
>in flowscript.
>
>Following is the snippet in my form definition file: -
>
>  <fd:submit id="submit" action-command="submit form">
>   <fd:on-action>
>     <fd:javascript>
>       validateRequired(event.source.parent);
>    </fd:javascript>
>   </fd:on-action>
> </fd:submit>
>
>And this is what I have in my flowscript: -
>
>function validateRequired(wid) {
>
>  print("Calling validateRequired");
>  print("get children " + wid.getChildren());
> 
>  var widIter = wid.getChildren();
>  
>  while (widIter.hasNext()) {
>    var widObj = widIter.next();
>   
>	print("Widgets are "+ widObj.getValue() + " Is required " +
>widObj.isRequired());
>    
>	if (widObj.isRequired && widObj.getValue() == null) {
>     
>      widObj.setValidationError(new
>Packages.org.apache.cocoon.forms.validation.ValidationError("Please
>enter a value for the required field"));
>    }
> }
>}
>
>The above code throws an error as follows: -
>
>setValidationError is not a function.
>
>I browsed the Cocoon API. I can see that setValidation Error is a method
>in the Field Class of the FormModel package.
>
>Can anyone help me in pointing out what could be wrong in the above
>code.
>
>Cheers
>Baskar
>
>
>
>Confidentiality Notice
>
>The information contained in this electronic message and any attachments to this message are intended
>for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
>you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
>and destroy all copies of this message and any attachments.
>
>---------------------------------------------------------------------
>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