Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using XML Schema (XSD) for input validation

 
Rory Newton
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Does anyone know if it is possible to use the facets of an XML Schema element to validate input to a form. So, for example if one had the following snippet in an XSD file somehow referenced to a JSF component:

<xs:element name="length">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>

an error would be triggered if a value of '11' was entered. I've seen similar things done with XForms, but I would really like to stick with JSF. Any help much appreciated.

Thanks.

Rory
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF has its own validation system. You could probably create an XSL to take an XForms definition and transform it into a JSF View, but the elements involved are totally different.

In addition to the basic JSF validators, you might also be interested in the MyFaces validator extensions, which allow JSF-based views to validate based on annotations in the backing beans and in the domain model objects.

IIRC, JBoss Seam also devotes a fair amount of coverage to input validation.

There's a whole standard in the works for validations, but it's still in progress.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic