I've put together a composite component that looks something like this:
Code: Select all
<cc:implementation>
<h:form id="formId" ...>
<h:inputText id="inputFieldId" .../>
<h:graphicImage id="imageId" .../>
<h:form/>
<script type="text/javascript">
SelectItem.setup(
{
inputField : "#{p:component('inputFieldId')}",
image : "#{p:component('imageId')}"
}
);
</script>
<cc:implementation/>
If you have more than one instance, the reference obtained by the p:component functions are are the same.
As a result, the ids passed into the setup() function for both components are the same.
I figured that to get around this, I would make the ids attributes, so I end up with something that looks like this:
Code: Select all
<cc:interface>
<cc:attribute name="textField" required="true" />
<cc:attribute name="image" required="true" />
</cc:interface>
<cc:implementation>
<h:form id="formId" ...>
<h:inputText id="#{cc.attrs.textField}" .../>
<h:graphicImage id="#{cc.attrs.image" .../>
<h:form/>
<script type="text/javascript">
SelectItem.setup(
{
inputField : "#{p:component(?????)}",
image : "#{p:component(?????)}"
}
);
</script>
<cc:implementation/>
The problem is I don't know the correct syntax for the p:component functions in the following:
inputField : "#{p:component(?????)}",
image : "#{p:component(?????)}"
Any suggestions on how to pass an expression like ="#{cc.attrs.textField}" into a p:component() function in this context?
Thanks.