We are in the process of migrating from RichFaces to PrimeFaces.
One of the challenges we are currently facing is the prepopulating the contents of a modal dialog in a dynamic fashion.
We have a modal panel for editing account information. This modal panel is called from various places throughout our application. The modal panel has a backing bean that includes all the business logic and responsible for the loading of the data to display in the modal panel. When invoking a modal panel, we also pass an id that the backing bean uses to load the content from the database to be presented in the modal panel.
We came up with the following code that properly sets the key and loads the data properly within the backing bean
Code: Select all
<h:form prependId="false">
<p:remoteCommand name="setAccountId">
<f:setPropertyActionListener value="#{clientDashboard.selectedAccount.id}" target="#{manageAccount.accountId}" />
</p:remoteCommand>
<p:commandButton value="Edit Account Profile"
onclick="setAccountId();"
actionListener="#{manageAccount.loadAccount}"
oncomplete="AccountWidget.show()">
</p:commandButton>
</h:form>
We tried adding an update attribute to the commandButton tag above setting the value to the id of the entire modal dialog or a panel within the modal dialog. In neither case did the modal panel display the dynamically loaded data.
In Richfaces, we could do the following:
Code: Select all
<a4j:commandLink ajaxSingle="true" oncomplete="Richfaces.showModalPanel('editAnnouncementModalPanel', {width:700, top:200});" reRender="editAnnouncementPanel">
<f:setPropertyActionListener target="#{editAnnouncement.announcementId}" value="#{i.id}"/>
edit<br/>
</a4j:commandLink>
What's the best practice for accomplishing this use case with PrimeFaces?
Thanks!
Dave