The third p:tab page shows a p:dataTable of records. The UI to add/edit/view the record detail is via a p:dialog and this is where the weirdness enters.
Above the p:dataTable is a p:commandButton for "Adding" a record:
Code: Select all
<p:commandButton id="cmdAdd"
value="#{messages.getString('application.label.cmdAdd')}"
actionListener="#{infoRequestCommentList.addListener}"
oncomplete="PF('infoRequestCommentEditModal').show()"
process="@this" update="infoRequestCommentEditPanel" >
<f:param name="cid"
value="#{javax.enterprise.context.conversation.id}" />
</p:commandButton>
The last column of the p:dataTable is a p:column called Action. Within each row of this column, there is a p:splitButton with a default command of Edit and a secondary of View.
No matter the sequence of events, clicking the button results in the backing bean logic firing (the rowData is extracted, the id used in a CDI event firing to make the edit bean update its data view, etc. However, when the p:dialog finally appears, IT IS COMPLETELY EMPTY OF ALL CONTENT! Not that the fields are empty, no. There ARE NO FIELDS, LABELS, OR BUTTONS just the appropriate title (Add/Edit/View X) appears.
My current p:dialog is defined as such:
Code: Select all
<p:outputPanel id="infoRequestCommentEditPanel">
<p:dialog id="infoRequestCommentEditModalId"
widgetVar="infoRequestCommentEditModal"
resizable="false" modal="true" closable="true" height="700"
width="1000" closeOnEscape="true" appendTo="@(body)"
onshow="PF('subject').focus();">
<f:facet name="header">
<h:panelGroup>
<h:outputText
value="#{messages.getString('infoRequestCommentEdit.label.add')}"
rendered="#{infoRequestCommentDTOEdit.baseActionPageModeEnum eq 'ADD'}" />
<h:outputText
value="#{messages.getString('infoRequestCommentEdit.label.edit')}"
rendered="#{infoRequestCommentDTOEdit.baseActionPageModeEnum eq 'EDIT'}" />
<h:outputText
value="#{messages.getString('infoRequestCommentEdit.label.view')}"
rendered="#{infoRequestCommentDTOEdit.baseActionPageModeEnum eq 'VIEW'}" />
</h:panelGroup>
</f:facet>
<h:form id="infoRequestCommentEditForm">
...
Not shown above, I had dyamic="true" set on the p:dialog. I removed that altogether and now the UI is being RENDERED, but the update is not happening. I can click on a row (say for id #2) and it appears with the Edit header and data in the fields, but only with the previous row's values. How do I know this? I REFRESH the entire page, the TV repaints, I click on the Comments tab, click any row in the dataTable and voi la: I see the row data I had clicked on previously.
I do not understand what is going on.
While I'm on the subject of dialogs, I use append="@(body)" to avoid both complicated update= names as well as any other conflicts if I want to use the p:dialog on other pages (via ui:include).
In fact, I have a small set of such dialogs (showTextModal, showImageModal, etc), each with their own "controller" backing bean that can be injected into a page's main controller bean, which is then pre-populated on demand, so that when the .show() is called, the UI appears as expected.
What is the best way to modularize such modal dialogs? I want them to be usable where ever needed, so some I include on every page at the bottom of my page template.
I have tried various order combinations of p:outputPanel / p:dialog / h:form and I think that is best (?) because when I update the panel I want the entire p:dialog re-rendered, not just the "body" of it. Is this a good best practice?