开发者

jsf and primefaces update problem

开发者 https://www.devze.com 2023-02-16 00:34 出处:网络
I have a JSF page with two forms (pseudo-code below). First form is for a user and has text fields and a table of phone numbers, and a link for

I have a JSF page with two forms (pseudo-code below).

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.

The problem I have is after the p:dialog closes, I want the list is not getting updated. 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.

SHORT VERSION OF MY QUESTION: The p:dialog has an attr update="phonesPanel" but phonePanel is in a different form; how do I do something like update="personForm.phonesPanel" so it updates the list which is in a different form?

<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:messa开发者_运维百科ges />
     <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":

<h:form prependId="false">

This way you don't need to use the nested id's and might use:

update="phonesPanel" 


I doubt that update="personForm:phonesPanel" works without a ":" before personForm. This should be the correct one:

update=":personForm:phonesPanel"


Answering my own question.

The answer is: update="personForm:phonesPanel"

Thanks all!

0

精彩评论

暂无评论...
验证码 换一张
取 消