Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 通过componentgetClientId(上下文)获取带冒号的组件id_Jsf 2_Primefaces_Jsf 2.2 - Fatal编程技术网

Jsf 2 通过componentgetClientId(上下文)获取带冒号的组件id

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">

我正在使用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">
    <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
如上所述,它是有效的