Primefaces - 无法在数据表之外找到带有标识符的组件 [英] 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>
这是我第一次使用 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 以 output 结尾的组件.查看 JQuery 文档了解更多信息.
This expression stands for every component whose id ends with output. Take a look at the JQuery docs for more info.
这篇关于Primefaces - 无法在数据表之外找到带有标识符的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!