Primefaces-无法找到数据表外部具有标识符的组件 [英] Primefaces - Cannot find component with identifier outside the datatable

查看:85
本文介绍了Primefaces-无法找到数据表外部具有标识符的组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <ui:define name="content">
    <f:view>                        
    <h:form id="myForm" styleClass="form" >

        <p:dataTable var="provider" id="ss"  value="#{providerSelectBean.providerList}" rowKey="#{provider.license}"  

            selection="#{providerSelectBean.selectedProvider}" selectionMode="single"> 

            <p:ajax listener="#{providerSelectBean.onRowSelect}"    
                            update=":myForm:output"event="rowSelect"/>  

            <p:column sortBy="#{provider.license}" width="110" >
                <f:facet name="header">
                    <h:outputText value="License#" />
                </f:facet>
                <h:outputText value="#{provider.license}" />
            </p:column>

            <p:column sortBy="#{provider.prgName}" width="110" >
                <f:facet name="header">
                    <h:outputText value="Program Name" />
                </f:facet>
                <h:outputText value="#{provider.prgName}" />
            </p:column>

        </p:dataTable><br/>

        <p:panelGrid id="output" >
            <h:outputText value="License" />
            <h:outputText value="#{provider.license}" /> 
        </p:panelGrid>

    </h:form>           
    </f:view>

</ui:define>    

这是我第一次使用JSF2.0和primefaces 3.4.1,并且<p:ajax update给出了错误

This is my first stint with JSF2.0 and primefaces 3.4.1 and the <p:ajax update gives an error

javax.faces.FacesException: Cannot find component with identifier  
":myForm:output"  referenced from "myForm:ss"

推荐答案

尝试检查生成的HTML代码,查看为panelGrid生成的实际ID,并更新该ID.如果碰巧是动态的,则可以始终使用JQuery CSS选择器(我发现自己经常这样做).就您而言,您可以这样:

Try to inspect the generated HTML code and see the actual id being generated for your panelGrid and update that id. If it happens to be dynamic, you can always use the JQuery CSS selectors (I find myself doing that pretty often). In your case, you can go like this:

update="@([id$=output])"

此表达式代表ID以输出结尾的每个组件.看看JQuery文档以了解更多信息.

This expression stands for every component whose id ends with output. Take a look at the JQuery docs for more info.

这篇关于Primefaces-无法找到数据表外部具有标识符的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆