JSF2 - Problems with Composite Components and Validatiors
Posted
by
Shadowman
on Stack Overflow
See other posts from Stack Overflow
or by Shadowman
Published on 2012-08-30T01:18:13Z
Indexed on
2012/08/30
3:38 UTC
Read the original article
Hit count: 245
I've created some Facelets to make developing our pages easier. Particularly, I've created a series of Facelets for input components. I have 1 Facelet, <xxx:input />
that displays a label around the input field. Beyond that, I have Facelets like <xxx:inputText />
and <xxx:inputSecret />
that render the actual input field. Each of these makes use of <xxx:input />
to display the label. The Facelet looks something like this:
<html ...>
<composite:interface>
...
</composite:interface>
<composite:implementation>
<label><h:outputText value="#{cc.attrs.labelText}" /></label>
<composite:insertChildren />
</composite:implementation>
</html>
The <xxx:inputText />
Facelet would then look like this...
<html ...>
<composite:interface>
...
</composite:interface>
<composite:implementation>
<xxx:input labelText=...>
<h:inputText id="myinput" ... />
</xxx:input>
</composite:implementation>
</html>
Everything renders just fine, but I am having troubles when trying to add <f:validator />
or other validation tags. From what I've read, I have to add a tag to my Facelet. So, I added <composite:editableValueHolder name="myinput" targets="myinput" />
line in the interface section. However, I still do not see my validator being fired. I have something like this in my .xhtml file...
...
<xxx:inputText value="...">
<f:validateLength minimum="10" />
</xxx:inputText>
...
Regardless of the input I enter, the validator never seems to fire and I never get an error message. A coworker suggested that it is due to the target ID I am using and the fact that it is wrapped by the <xxx:input />
Facelet.
Do I need to incorporate the parent component ID in my target definition? Is there something else that I'm missing? It works just fine if I exclude the <xxx:input />
Facelet, so I'm assuming it's something related to that, but don't know how to solve it. Any help you can provide is GREATLY appreciated.
© Stack Overflow or respective owner