You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Richard Eggert <re...@proteus-technologies.com> on 2007/03/30 19:46:51 UTC

Using validators with Clay

I've been trying to get a custom validator working with Clay, but so far I haven't figured out how to do it.

I have a class named "a.b.c.IPAddressValidator" that validates that a String is a valid dotted-decimal IP address, as its name implies.  I've registered in my faces-config under the validator-id "a.b.IPAddress".  

It works fine when I invoke it using JSP (i.e., using <f:validator validatorId="a.b.IPAddress" /> nested within a <h:input> element).

However, I have not been able to get it to work with Clay views defined either in HTML or XML.

I tried this:

<component jsfid="my:inputIPAddress" extends="t:inputText">
   <element renderId="0" jsfid="f:validator">
      <attributes>
         <set name="validatorId" value="a.b.IPAddress" />
      </attributes>
   </element>
</component>

but I got the error "Undefined component type override", presumably because the clay-config.xml that comes with Clay defines "f:validator" with a componentType of "override".

I also tried this (as XML and also in the equivalent HTML using span tags):

<component jsfid="my:validateIPAddress" componentType="a.b.IPAddress" extends="validator">
</component>

<component jsfid="my:inputIPAddress" extends="t:inputText">
   <element renderId="0" jsfid="my:validateIPAddress" />
</component>

but that resulted in the error "Undefined component type a.b.IPAddress".

I also tried swapping out my validator with the f:validateLongRange validator, with the same result.


How do I get this to work?  The only examples of validation in the Clay intro page show it being done with managed bean methods and the "validator" attribute.


Rich Eggert
Member of Technical Staff
Proteus Technologies, LLC
http://www.proteus-technologies.com