JSF 2.0.3 PrimFaces 2.2 and JSR 303

UI Components for JSF
Post Reply
tkelly
Posts: 3
Joined: 31 Jan 2011, 17:12

31 Jan 2011, 17:19

Hi,

My environment:
JSF 2.0.3
PrimeFaces 2.2.RC2
Tomcat 6
JDK 1.6

I am looking to use hibernate bean validator for my model beans is this currently supported ? - I am looking for something similar to richfaces beanValidator functionality. I thought that JSF 2 supported JSR 303 and I am surprised not to see any examples on the showcase - can you confirm if this is supported or not ?

Thanks,

T.

tkelly
Posts: 3
Joined: 31 Jan 2011, 17:12

31 Jan 2011, 18:37

Hi,

Can anyone let me know if this is possible ? - if not I can investigate some work arounds and post the code accordingly.

Thanks,

T.

marcbaechinger
Posts: 25
Joined: 28 Jan 2011, 15:18

31 Jan 2011, 19:47

hi tkelly

jsr303 works fine for me with primefaces. See my maven dependencies below

Most important for JSR-303 is the hibernate-validator dependency. Once you have it in your classpath jsf2 does the rest automatically. Really nice.

cheers
marc

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.2.GA</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>


<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.3-b03</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.3-b03</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.RC2</version>
</dependency>

tkelly
Posts: 3
Joined: 31 Jan 2011, 17:12

31 Jan 2011, 20:01

Hi Marc,

Good to know that you have it set-up and working for you.

I have similar jars as yourself but was trying to get validation working with the p:wizard tag. Once I know it's possible i will get a spike project set-up and post some code.

Thanks for your response.

T.

dxxvi
Posts: 10
Joined: 22 Oct 2009, 12:42

21 Feb 2011, 06:54

Wow! You guys are genius.

I saw this "Client Side Validation" in RichFaces 4 http://in.relation.to/Bloggers/RichFace ... Validation. If you're too lazy to follow the link I gave and if you trust me in corectly comprehending that article, this is its idea: the bean validations on the server side can be copied to the client side if possible. For example, this bean validation

Code: Select all

@Size(min=3, max=12) private String name;
can be brought to the client side like this

Code: Select all

<h:inputText value="#{userBean.name}">
    <rich:validator/>
</h:inputText>
. I haven't tried it yet but I think the client side validations will be triggered when the form is submitted. In case we need to trigger the validation way before the form is submitted, we can write

Code: Select all

<rich:validator event="keyup"/>
. It's nice, isn't it?

Do we have anything similar or better in PrimeFaces?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 68 guests