4

I'm using below composite component:

<composite:interface>
    <composite:attribute name="inputId" />
</composite:interface>
<composite:implementation>
    <h:panelGrid id="myTableId">
        <h:inputText id="#{cc.attrs.inputId}" value="..." />
        ...
    </h:panelGrid>
</composite:implementation>

And I'm using it in my form as below:

<h:form id="myForm">
    <myCompositeComp:test inputId="myInputTextBoxId" />
<h:form>

I've verified the view source for the page and this is how it is generated:

<table id="myForm:j_idt90:myTableId">
    ...
    <input type="text" id="myForm:j_idt90:myInputTextBoxId" />
</table>

How can I get rid of j_idt90 here? Is it the id of my composite component? I read from one of BalusC post that this issue will get fixed if I declare id as static. But I'm not able to identify the place to declare it in my code. Also can I assume <h:panelGrid> is a kind of UINamingContainer?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
MyFist
  • 413
  • 7
  • 19

1 Answers1

7

Yes it is the id of your composite component, <h:panelGrid> is not a UINaminContainer but the composite component is (it has to be, otherwise you would have duplicate IDs if you use it several times inside the same form for example).

Why do you need to get rid of the ID? You can set it yourself if that solves your problem:

<h:form id="myForm">
    <myCompositeComp:test id="myComp" attr1="" attr2="" />
<h:form>

the genereated html should look like this:

<table id="myForm:myComp:myTableId">
        ....
        <input type="text" id="myForm:myComp:myInputTextBoxId"
</table>
Robin
  • 538
  • 1
  • 3
  • 13
  • Thanks a lot. It is working now. I was under impression that a composite component will have no ID on its own. – MyFist Dec 04 '12 at 07:33