简体   繁体   English

jsf和primefaces更新问题

[英]jsf and primefaces update problem

I have a JSF page with two forms (pseudo-code below). 我有一个有两种形式的JSF页面(下面是伪代码)。

First form is for a user and has text fields and a table of phone numbers, and a link for adding a new phone number. 第一种形式是针对用户的,具有文本字段和电话号码表,以及用于添加新电话号码的链接。

Second form is the p:dialog that shows the form for adding a phone number to the list. 第二种形式是p:对话框,显示用于向列表添加电话号码的表单。

The problem I have is after the p:dialog closes, I want the list is not getting updated. 我的问题是在p:对话框关闭后,我希望列表没有得到更新。 If I put the p:dialog tag inside the first form, the list does get updated but there are two separate forms because I need their contents to be validated in separate actions. 如果我将p:dialog标记放在第一个表单中,列表会更新,但有两个单独的表单,因为我需要在单独的操作中验证它们的内容。

SHORT VERSION OF MY QUESTION: The p:dialog has an attr update="phonesPanel" but phonePanel is in a different form; 我的问题的简短版本:p:对话框有一个attr update =“phonesPanel”,但是phonePanel的格式不同; how do I do something like update="personForm.phonesPanel" so it updates the list which is in a different form? 我该怎么做像update =“personForm.phonesPanel”这样的东西,以便更新不同形式的列表?

<h:form id="personForm">

  <p:messages />

  <h:inputText label="Full Name" value="... />

  <p:commandLink value="Add Phone Number" onclick="dlg.show();" />

  <h:panelGrid id="phonesPanel" columns="1" style="width:100%" >
    <h:dataTable id="phonesTable">
      // ...
    </h:dataTable>
  </h:panelGrid>

</h:form>


<h:form>

  <p:dialog id="dialog" modal="true" widgetVar="dlg">
     <p:messages />
     <h:inputText label="Phone Number" value="... />
     <p:commandButton value="Add Phone Number" update="phonesPanel"   
       actionListener="#{handler.doAddPhoneNumber}" 
       oncomplete="handleLoginRequest(xhr, status, args)"/>  
  </p:dialog>

</h:form>

Any help is greatly appreciated! 任何帮助是极大的赞赏!

rob

Other thing you can do is set the "prependId" form attribute to "false": 您可以做的其他事情是将“prependId”表单属性设置为“false”:

<h:form prependId="false">

This way you don't need to use the nested id's and might use: 这样您就不需要使用嵌套ID了,可能会使用:

update="phonesPanel" 

I doubt that update="personForm:phonesPanel" works without a ":" before personForm. 我怀疑update =“personForm:phonesPanel”在personForm之前没有“:”。 This should be the correct one: 这应该是正确的:

update=":personForm:phonesPanel"

Answering my own question. 回答我自己的问题。

The answer is: update="personForm:phonesPanel" 答案是:update =“personForm:phonesPanel”

Thanks all! 谢谢大家!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM