2

I have a Primefaces JSF view myView.xhtml with a form (with id 'myformID') and datatable (with id 'myDataTableId') in it. I also have a dialog box (myDialog.xhtml). I am including the myDialog.xhtml in myView.xhtml. When we click on the commandButton in 'myDialog.xhtml', it will update a datatable after executing the method specified in action listener. I am updating the datatable with update=":myFormId:myDataTableId"and it is working fine.

But I would like to use the same dialog in different view. The form id and datatable id are different in that view. So, how can I reuse the dialog and update datatables with different id's (currently I am creating one more dialog by duplicating the code and changed the value in the update attribute of commandButton accordingly)?

4

1 回答 1

2

您可以通过示例传递参数ui:include

大师.xhtml

<ui:include src="include.xhtml">
    <ui:param name="customId" value="4567" />
</ui:include>

包含.xhtml

<ui:composition>
    <p:dialog id="#{customId}" ...>
    </p:dialog>
</ui:composition>
于 2013-05-27T09:27:11.767 回答