In a backing bean:
@Min(3)
Integer foo;
If I have form like:
<h:form>
<h:commandButton value="Submit" />
<h:inputText value="#{bean.foo}" />
</h:form>
This works ok. However, if I do something like
<cc:interface>
<cc:attribute name="text" />
<cc:editableValueHolder name="text" targets="field" />
<cc:interface>
<cc:implementation>
<h:inputText id="field" value="#{cc.attrs.text}" />
</cc:implementation>
and call this inside form instead of directly h:inputText
as in:
<!-- <h:inputText value="#{bean.foo}" /> -->
<pref:fieldComponent text="#{bean.foo}" />
But then I get:
javax.validation.ValidationException: Unexpected exception during isValid call
at org.hibernate.validator.engine.ConstraintTree.validateSingleConstraint(ConstraintTree.java:144)
at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:118)
at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:121)
at org.hibernate.validator.engine.ValidatorImpl.validateValueForGroup(ValidatorImpl.java:655)
...
And the root cause is:
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
at org.hibernate.validator.constraints.impl.MinValidatorForNumber.isValid(MinValidatorForNumber.java:32)
at org.hibernate.validator.engine.ConstraintTree.validateSingleConstraint(ConstraintTree.java:141)
... 69 more
If I remove validation, it works. Also, if foo
is of type String
, it works also with validations.
I tried playing with cc:editableValueHolder
, defining different types (also omitting it) and a few other tricks but I am a bit unsure how to actually implement this. Or is it a bug? Seems like it's forgetting to use a converter? Have I misunderstood something?