Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF 2.2 Composite Component EditableValueHolder

I'm writing a composite component that contains an <h:selectManyMenu> and I'd like to allow clients of this component to supply validators and converters by placing <f:validator> and <f:converter> tags as children of my composite component's tag. In my composite's interface section I have

<composite:editableValueHolder name="select-input" targets="select-many" />

and in the implementation section:

<h:selectManyMenu id="select-many" styleClass="hidden select-input" value="#{cc.attrs['value']}" binding="#{cc.inputComponent}">
  <composite:insertChildren />
</h:selectManyMenu>

and finally the usage:

<cwi:selectManyMenu id="select-many-menu" value="#{selectManyBean.selectedItems}">
  <f:converter converterId="converter.testItem" for="select-many" />
  <f:validator validatorId="validator.testItem" for="select-input" />
  <f:selectItems value="#{selectManyBean.possibleItems}" var="item" itemValue="#{item}" itemLabel="#{item.description}" />
</cwi:selectManyMenu>

The problem is neither the validator nor converter are called. I also have validator and converter classes, each annotated with @FacesValidator('validator.testItem') and @FacesConverter("converter.testItem"), respectively. They are being picked up correctly, because if I move the <f:validator> and <f:converter> tags inside the composite component, underneath <composite:insertChildren> everything works fine, but I'd rather expose these to clients than hardcode them. Is there something about the way insertChildren works when using editableValueHolder? To get this working, I could just make the converter and validator IDs part of the interface, but that loses some flexibility for passing attributes to the converters and validators.

like image 316
Matt Avatar asked Nov 19 '25 07:11

Matt


1 Answers

I am using Mojarra 2.2.8-jbossorg-1. Aside from the now obvious typo, I should also have included more of my composite component's xhtml. I was using a backing component, and without the backing component, everything worked fine once I fixed the typo, but when I added the backing component, the validator and converter stopped working.

After reviewing the wiki page here for composite components https://stackoverflow.com/tags/composite-component/info I realize backing components for composite components are not the same as the classes for custom components. For composite components, they should always just extend UINamingContainer. My mistake, for specifically this selectManyMenu, was that my backing component extend UISelectMany.

like image 140
Matt Avatar answered Nov 21 '25 10:11

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!