cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Nora <>
Subject JXForms and validation inside Flow
Date Fri, 30 Jan 2004 14:46:36 GMT
I've a problem with an application developed with Cocoon 2.1.3.

I'm trying to do validation inside a JXForm using Flow.

I'm using sitemap matches like this:

<!-- Here is called jxform -->
<map:match pattern="admin-*-form">
 <map:call function="jxform">
  <map:parameter name="function" value="{1}"/>
  <map:parameter name="id" value="form-{1}"/>
  <map:parameter name="validatorNamespace" 
  <map:parameter name="validatorSchema" 

<!-- Here is "generated" jxform -->
<map:match pattern="admin-jxforms-*-xsp">
 <map:generate src="content/static/admin/{1}.xsp" type="serverpages"/>
 <map:transform type="jxforms" label="debug"/>
 <map:transform type="xslt" src="stylesheets/jxforms-default.xsl"/>
 <map:transform type="xslt" src="stylesheets/jxforms2html.xsl"/>
 <map:serialize type="xml"/>

XSP page which creates jxform (excerpt): basically outputs JXForm with inputs 
and selectS fetched from a DB source using ESQL.

<xf:form id="form-addresource" view="addresource" 
<!-- BTW: what does it mean and it MUST exists "error" element? -->
 <xf:violations class="error"/>
<!-- An input -->
<xf:input ref="/phone_number">
 <xf:label>bla bla</xf:label>
 <!-- it's REQUIRED violations in order to perform validation on this input? -->
 <xf:violations class="error"/>

And in my JS flow:

function addresource(form) {
 // Show jxform
  function(form) {
   // I use Database.js (PetShop sample) in order to query a DB and exceptions
   // to catch DB errors
   try {
    // Do SQL on datasource...
   } catch(e) {
    // Error coming from DBMS (ie. duplicate PK)
    // Add violation in jxform
    // User should see again this jxform with phone_number with Error!! string
    // showed
    form.addViolation("/phone_number", "Error!!");

Schematron for jxform is like this:
<phase id="addresource">
 <active pattern="checkphone"/>
<pattern id="checkphone" name="adduser validation pattern">
 <rule context="/phone_number">
  <assert test="string-length(.) &gt; 1">drin drin!!</assert>

The result is that cocoon, when user fill this jxform and there's an error, 
show again jxform but WITHOUT any string indicating ie. "drin drin!!" 
or "Error!!" as indicated in JS and schematron (which is desidered behaviour). 
I'm missing something? What are the exact steps in order to do jxform 
validation using JS?

Luca Nora

View raw message