cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject Re: Cross validation in bound CForms
Date Sat, 03 Jul 2004 18:10:03 GMT
On Sat, 2004-07-03 at 20:02, Colin Paul Adams wrote:
> >>>>> "Bruno" == Bruno Dumon <bruno@outerthought.org> writes:
> 
>     Bruno> This is probably because your fd:validation is inside your
>     Bruno> fd:datatype (where did you find that? I thought all
>     Bruno> examples and docs were updated)
> 
> They probably are - I missed the / at the end of the datatype line:
> 
> <fd:field id="yourmail">
>   <fd:datatype base="string"/>
>   <fd:validation>
> 
> Works better now.
> 
> But not correctly:
> 
> 	      var success = true;
> 	      var start_time = widget.lookupWidget("../start-time");
> 	      if (start_time.value = "") {
> 	      widget.setValidationError(new Packages.org.apache.cocoon.forms.validation.ValidationError("Start-time
must be specified along with finish-time", false));
> 	      success = false;
> 	      }
> 	      
> 	      // Must return true/false
> 	      return success;
> 
> My test:
> 
> if (start_time.value = "") is no good as I get:

that's because '=' is the assignment operator, ie you assign the empty
string "" as value of the start_time widget, which also explains the
error below:

> 
> org.mozilla.javascript.JavaScriptException: at foo (file:/home/colin/onevoice/members/forms/event-form.xml,
Line 51): 
> java.lang.RuntimeException: Incorrect value type for "events.0.start-time" (expected
class java.util.Date, got class java.lang.String). 
> 
> I tried changing the "" to null, but then I don't get a validation
> error.
> 
> What is the corect way to discover that the user has not typed
> anything in the start-time field?

that would be: if (start_time.value == null)

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Mime
View raw message