首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何为Ajax更新/呈现查找组件的客户端ID?

如何为Ajax更新/呈现查找组件的客户端ID?
EN

Stack Overflow用户
提问于 2018-04-02 01:22:22
回答 2查看 0关注 0票数 0

下面的代码来自PrimeFaces DataGrid+DataTable教程

代码语言:txt
复制
<p:tabView id="tabs">
    <p:tab id="search" title="Search">                        
        <h:form id="insTable">
            <p:dataTable id="table" var="lndInstrument" value="#{instrumentBean.instruments}">
                <p:column>
                    <p:commandLink id="select" update="insTable:display" oncomplete="dlg.show()">
                        <f:setPropertyActionListener value="#{lndInstrument}" 
                                        target="#{instrumentBean.selectedInstrument}" />
                        <h:outputText value="#{lndInstrument.name}" />
                    </p:commandLink>                                    
                </p:column>
            </p:dataTable>
            <p:dialog id="dlg" modal="true" widgetVar="dlg">
                <h:panelGrid id="display">
                    <h:outputText value="Name:" />
                    <h:outputText value="#{instrumentBean.selectedInstrument.name}" />
                </h:panelGrid>
            </p:dialog>                            
        </h:form>
    </p:tab>
</p:tabView>
EN

Stack Overflow用户

发布于 2018-04-02 09:52:13

如果希望通过Ajax进程/EXECUTE/UPDATE/Render引用的组件在相同的NamingContainer

代码语言:txt
复制
<h:form id="form">
    <p:commandLink update="result"> <!-- OK! -->
    <h:panelGroup id="result" />
</h:form>
代码语言:txt
复制
<h:form id="form">
    <p:commandLink update="result"> <!-- FAIL! -->
</h:form>
<h:panelGroup id="result" />
代码语言:txt
复制
<h:form id="form">
    <p:commandLink update=":result"> <!-- OK! -->
</h:form>
<h:panelGroup id="result" />
代码语言:txt
复制
<h:form id="form">
    <p:commandLink update=":result"> <!-- FAIL! -->
</h:form>
<h:form id="otherform">
    <h:panelGroup id="result" />
</h:form>
代码语言:txt
复制
<h:form id="form">
    <p:commandLink update=":otherform:result"> <!-- OK! -->
</h:form>
<h:form id="otherform">
    <h:panelGroup id="result" />
</h:form>

或者尝试下

代码语言:txt
复制
<p:tabView id="tabs"><!-- This is a NamingContainer -->
    <p:tab id="search"><!-- This is NOT a NamingContainer -->
        <h:form id="insTable"><!-- This is a NamingContainer -->
            <p:dialog id="dlg"><!-- This is NOT a NamingContainer -->
                <h:panelGrid id="display">

生成的HTML输出<h:panelGrid id="display">看起来像这样:

代码语言:txt
复制
<table id="tabs:insTable:display">

你得把这个id作为客户端ID,然后以:用于update:

代码语言:txt
复制
<p:commandLink update=":tabs:insTable:display">

票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100003248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档