无法在Java Faces中查找组件

时间:2013-09-13 15:56:05

标签: primefaces

我正在研究Java Servlet Web应用程序,我在页面上遇到错误。我有commandButton

 <p:commandButton update="numbersEventFeedsForm" oncomplete="numbersEventFeedsDialog.show()"
                  icon="ui-icon ui-icon-search" title="view increments" style="height:20px;">
      <f:setPropertyActionListener value="#{numbersEvent}" target="#{searchBean.selectedNumbersEvent}"/>
 </p:commandButton>

我已经宣布了我的表格:

<h:form id="numbersEventFeedsForm">
    <p:dialog header="Feeds" widgetVar="numbersEventFeedsDialog" resizable="false" width="1000"
          styleClass="dialog">
         <!-- Etc -->

    </p:dialog>
</h:form>

但我收到以下错误:

 Sep 13, 2013 4:32:33 PM  com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
 SEVERE: javax.faces.FacesException: Cannot find component with identifier "numbersEventFeedsForm" in view.

我很清楚错误发生的原因。我已经阅读了其他问题,以确保我在update id <form>前加{{1}}属性作为前缀,但我没有那个属性,所以我有点陷入困境在这一点上!

1 个答案:

答案 0 :(得分:0)

@christopher。

首先,您的表单“numbersEventFeedsForm”应保留在p:对话框中。

如果您在页面的整页中使用“p:layout”,则还需要在p:对话框中定义属性“appendTo =”@(body)“,以使其成为直接子项身体标签。如果没有,你的对话可能不会出现。

然后当尝试在对话框中更新表单时,您应该使用“:numbersEventFeedsForm”来更新表单,除非将commandButton放在引用的“表单”中,在这种情况下您不需要“:”前缀

尝试进行此调整,看看是否有效..