-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: SizeValidatorForCharSequence -Primefaces Chips Web Component
PostPosted: Tue May 30, 2017 1:42 pm 
Newbie

Joined: Tue May 30, 2017 1:17 pm
Posts: 1
Hi!

I've made the question below in https://forum.primefaces.org/viewtopic.php?f=3&t=51091, and the Primefaces Core Developer Thomas Andraschko give me a hint to try getting answers here ("Try to ask the hibernate validator guys. It seems like it uses getter and the property and those types doesn't match").

Well, I have a CRUD and I want to change the inputTexArea:
Code:
<p:inputTextarea id="tags" value="#{myController.selected.tags}" />

To the new Primefaces <b>chips</b> component:
Code:
<p:chips id="tags" value="#{myController.selected.tags}" />

An entity class excerpt:
Code:
@Lob
@Size(max = 2147483647)
@Column(name = "tags")
private String tags;
//GETTER AND SETTER OMITTED

The get method works fine, since the tags are displayed in the field as expected:
Code:
public List<String> getTags() {
return Arrays.asList(tags.split(","));
}

But the set method is not, because when I click on Save, occurs an Exception:
Code:
public void setTags(List<String> tags) {
this.tags = String.join(",", tags);
}
//excerpt of the Exception:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.CharSequence
at org.hibernate.validator.internal.constraintvalidators.SizeValidatorForCharSequence.isValid(SizeValidatorForCharSequence.java:33)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:281)

Can you guys, please, help me?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: SizeValidatorForCharSequence -Primefaces Chips Web Component
PostPosted: Tue May 30, 2017 2:00 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I moved the topic to the Validator forum.


Top
 Profile  
 
 Post subject: Re: SizeValidatorForCharSequence -Primefaces Chips Web Component
PostPosted: Mon Jun 05, 2017 8:44 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Marcel,

the annotations are defined on the field so Validator is expecting to validate the Java type of the field, which is a String.

Getters and setters should match the same type (so return a String and accept a String, not a a List):
- http://beanvalidation.org/1.1/spec/#con ... quirements

Even so, seems like Hibernate Validator should have used field access in your example.
Please share the version of Hibernate Validator you're using, to see if we need to create a new bug in our issue tracker.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.