[英]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? 我怎样才能摆脱j_idt90
? Is it the id
of my composite component? 它是我的复合组件的id
吗? I read from one of BalusC post that this issue will get fixed if I declare id
as static. 我从BalusC的一篇文章中读到,如果我将id
声明为静态,这个问题将得到解决。 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
? 我还可以假设<h:panelGrid>
是一种UINamingContainer
吗?
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). 是的,它是复合组件的id, <h:panelGrid>
不是UINaminContainer
但复合组件是(必须是,否则如果在同一表单中多次使用它,则会有重复的ID)。
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: 生成的html应如下所示:
<table id="myForm:myComp:myTableId">
....
<input type="text" id="myForm:myComp:myInputTextBoxId"
</table>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.