Jsf 2 通过componentgetClientId(上下文)获取带冒号的组件id
我正在使用PF5.0和JSF2.2.8,下面有代码Jsf 2 通过componentgetClientId(上下文)获取带冒号的组件id,jsf-2,primefaces,jsf-2.2,Jsf 2,Primefaces,Jsf 2.2,我正在使用PF5.0和JSF2.2.8,下面有代码 <ui:composition template="/template/mastertemplate.xhtml"> <ui:define name="content"> <f:view> <h:body> <h:form id="bcr_form_2" styleClass="form"> <p:tabView id="bcrId_tabview">
<ui:composition template="/template/mastertemplate.xhtml">
<ui:define name="content">
<f:view>
<h:body>
<h:form id="bcr_form_2" styleClass="form">
<p:tabView id="bcrId_tabview">
<p:tab title="Budget Cash Demands">
<h:panelGrid>
<p:commandButton value="save" id="saveDemandId_cmdbutton"
action="#{budgetControlRegisterAction.saveNewDemand()}"
binding="#{budgetControlRegisterAction.myMessageCId}"
update=":#{p:component('saveId_message')}">
</p:commandButton>
<p:message id="saveId_message" for="saveDemandId_cmdbutton" ></p:message>
</h:panelGrid>
</h:form >
<!-- and all closing tags-->
如何通过myMessageCId.getClientId(上下文)方法获取客户端Id(不带冒号) 我刚刚尝试了你的代码(我对你的第二个添加消息
,放置@RequestScoped并删除组合
),它在Primefaces 5.1和Mojarra 2.2.8上运行得非常好!
我注意到您的日志输出是:
client Id :bcr_form_2:bcrId_tabview:saveDemandId_cmdbutton
bcr_form_2:bcrId_tabview:saveDemandId_cmdbutton
但请注意日志行代码:
log.info("client Id :" + myMessageCId.getClientId(context));
前导分号已从字符串串联中引入。因此,实际产出是:
client Id :bcr_form_2:bcrId_tabview:saveDemandId_cmdbutton
bcr_form_2:bcrId_tabview:saveDemandId_cmdbutton
如上所述,它是有效的