即使在使用update属性后,PrimeFaces组件也未更新

时间:2016-01-10 17:13:29

标签: jsf primefaces jsf-2.2

我有2页。第1页显示数据表中的用户列表,其中包含2个用于创建新用户和编辑现有用户的按钮。单击“创建和编辑”按钮,将打开一个带有输入框和保存按钮的弹出窗口(第2页)。

我面临的问题是如果我点击创建(在第1页上),Page2会打开。如果我在输入框名称中输入内容,单击取消,然后在Page1上的数据表中选择现有行并单击编辑,再次打开Page2,并且保留我在创建按钮单击时输入的任何内容,即使我没有更新PrimeFaces组件单击取消按钮捕获对话框的onClose事件并重新初始化我的视图对象。

第1页:

<ui:composition template="template.xhtml>"
<ui:define name="center" >
<h:form id="myForm1">
  <h:panelgroup id="panel1">
  <p:datatable ..... />

此数据表显示用户列表

  <p:panelGrid id="buttonMenu1" >
   <p:commandButton id="Create" actionListener="#{myBean1.onCreate}" oncomplete="PF('id2Var').show();" update=":myForm2" />
  </p:panelGrid>
  </h:panelGroup>
</h:form>
</ui:define>
<ui:define name="dialog">
<ui:include src="Page2" />
</ui:define>
</ui:composition>

2页:

<p:dialog id="id2" widgetVar="id2Var" >
<p:ajax event="close" listener="#{myBean.onClose}" update=":myForm2" />
<h:form id="myForm2">
  <h:panelgroup id="panel2">
  <p:outputLabel value="Name" />
  <p:inputText id="name" value="myBean.myList.name" />
  <p:panelGrid id="buttonMenu" >
   <p:commandButton id="Save" actionListener="#{myBean.onSave}" update=":myForm2" />
   <p:commandButton id="Cancel" actionListener="#{myBean.resetInput}" update=":myForm2" oncomplete="PF('id2Var').hide();" />
 </p:panelGrid>
</h:panelgroup
</h:form>
</p:dialog>

0 个答案:

没有答案