Gerry Kaplan wrote:
I need some help. I have a multi-page form which is defined similarly to the
multipage sample. The form is a self-registration form. The user's e-mail
address is used as their user-id. The first page contains a field "email".
The page needs to validate that the email address hasn't already been
registered in the system. I want to keep the validation code separate from
the form because, in the near future, the validation process will change to
using an LDAP.
I have been able to get javascript code to execute in a validation block in
the first page's <fd:struct>, but I don't know how to provide a bean or
anything to that validation code. I've tried just passing a string from the
flow script, but it seems I can't work with it in the model section. Here's
a snippet of the flow, followed by a snipped of the model. If anyone can
help, I'd be grateful.

If I understand your problem correctly, you should be able to use a javascript validator on the email widget, something like:

<fd:field id="email" required="true">
  <fd:label>E-mail:</fd:label>
  <fd:datatype base="string" />
  <fd:validation>
    <fd:email/>
    <fd:javascript>
      var isValid = validateEmailAddress(widget.getValue());
      if(!isValid) {
        widget.setValidationError(
          new Packages.org.apache.cocoon.forms.
                 validation.ValidationError("Address already used.")
        );
      }
      return isValid;
    </fd:javascript>
  </fd:validation>
</fd:field>

...where validateEmailAddress() is a function defined externally that performs the validation (whether it's LDAP or whatever) and returns true or false. You can also call out to a Java method for that validation if that's how it's implemented.

Please respond to [EMAIL PROTECTED], as I'm not sure where
responses are posted. Thanks much!

CC'd. I'd suggest you subscribe to the list, though, as any further discussion will take place there. A link to list archives is on http://cocoon.apache.org/community/mail-lists.html



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to