Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of the auto generated j_idt ID in composite component

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?

like image 805
MyFist Avatar asked Oct 20 '25 19:10

MyFist


1 Answers

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>
like image 64
Robin Avatar answered Oct 24 '25 19:10

Robin



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!