Reputation: 16273
I am not able to display a p:dialog
with prefilled values for a p:inputText
component:
<p:dialog modal="true" widgetVar="editPersonDlg" header="Edit Person" width="350">
<h:form id="editPersonForm">
<h:panelGrid columns="2">
<h:outputLabel for="editFirstName" value="First Name:" />
<p:inputText id="editFirstName" value="#{personBean.selectedPerson.firstName}" />
<p:commandButton value="Save" type="Button" actionListener="#{personBean.edit}"
oncomplete="editPersonDlg.hide()"/>
<p:commandButton value="Cancel" type="Button" oncomplete="editPersonDlg.hide()"/>
</h:panelGrid>
</h:form>
</p:dialog>
When debugging I see that personBean#selectedPerson
is effectively returning a not-null Person, with not-null names. Person#getFirstName
is effectively returning a not-null name. However FirstName and LastName don't appear in the inputText boxes of the Dialog.
Upvotes: 0
Views: 1188
Reputation: 2427
It could be beacause you don't update the dialog before you open it. For example: You initialize the personBean.selectedPerson by selecting it in p:dataTable and then you want to edit it by clicking on p:commandButton which opens the "edit" dialog. You have to update this dialog so the component can fetch actual data. Try something like this for the button which opens the dialog:
<p:commandButton value="Edit" oncolmplete="editPersonDlg.show()" update=":formInWhichIsDialog:dialogID" />
Let me know if it worked, problem can be somewhere else but this is the most common thing. Hope it helped !
Upvotes: 2