cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emond Papegaaij <e.papega...@student.utwente.nl>
Subject Problem with cForms and validation
Date Mon, 15 Nov 2004 20:10:07 GMT
Hi,

We are using cForms with the standard cForms validation for some time now. A 
couple of days ago I decided to upgrade to the latest Cocoon snapshot, 
however with this snapshot the validation doesn't work as expected anymore. 
Somewhere a change has been made to the way Cocoon handles validation of 
fields that were left blank. It now tries to validate a null reference, which 
leads to a NullPointerException. I've seen this happen with 'normal' text 
fields, fields with a converter to Integer, aggregate fields with fd:regexp 
and with custom validation classes.

I don't think it makes sense to validate a null reference as it should always 
be considered correct when the field is not required. Reverting to Cocoon 
2.1.5.1 solved it, so it's definitely a problem introduced somewhere in the 
new Cocoon version. Is it a bug or is it the way it's supposed to be? It 
makes the combination of validation with non-required fields quite useless.

Best regards,
Emond Papegaaij

Here is a snapshot of the definition of a field that is causing problems when 
left blank:
<fd:aggregatefield id="poBoxZipCode">
  <fd:label>Postcode</fd:label>
  <fd:datatype base="string"/>
  <fd:split pattern="([1-9]{1}[0-9]{3}) ?([a-zA-Z]{2})">
    <fd:map field="digits" group="1"/>
    <fd:map field="letters" group="2"/>
  </fd:split>
  <fd:combine expression="Concat( digits, letters )"/>
  <fd:widgets>
    <fd:field id="digits">
      <fd:label>Postcode</fd:label>
      <fd:datatype base="string">
        <fd:validation>
          <fd:regexp pattern="[1-9]{1}[0-9]{3}">
            <fd:failmessage>CUT ERROR</fd:failmessage>
          </fd:regexp>
        </fd:validation>
      </fd:datatype>
    </fd:field>
    <fd:field id="letters">
      <fd:datatype base="string">
        <fd:validation>
          <fd:regexp pattern="[a-zA-Z]{2}">
            <fd:failmessage>CUT ERROR</fd:failmessage>
          </fd:regexp>
        </fd:validation>
      </fd:datatype>
    </fd:field>
  </fd:widgets>
</fd:aggregatefield>

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


Mime
View raw message