Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jsf - Primefaces - Cannot find component with identifier outside the datatable

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

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"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...