<containers>
<container name="dialogBean">
<regions>
<region number="0">queryForm</region>
<region number="1">queryResults</region>
<region number="2">selectedItems</region>
</regions>
<pageLayout>
<unit position="west">
<content>#{region_0}</content>
</unit>
<unit position="center">
<content>#{region_1}#{region_2}</content>
</unit>
</pageLayout>
</container>
</containers>
It is a border layout: region0(query) in the west layout unit; region1(queryResults)
and region2(selectedItems) in the center layout unit.
There are two ways to open a dialog:
public DialogBean getDialogBean(boolean create)
public DialogBean newDialogBean()
For example, open a new dialog from current containerBean, and add a
bean into region 2:
ContainerBean containerBean = ...;
DialogBean dialogBean = containerBean.newDialogBean();
EntityBackingBean bean = ContainerBean.createEntityBackingBean(..., dialogBean);
dialogBean.showBean(bean, 2);
The created dialogBean will be added as a partial RenderTarget.
A child dialogBean can be opened from a dialogBean in the same way. For example, Open a dialog to show an employee list from persistence:
DialogBean dialogBean = ...;
DialogBean childDialogBean = dialogBean.getDialogBean(true);
QueryCriteria<Employee, Employee> queryCriteria = new QueryCriteria<Employee, Employee>(Employee.class);
EntityDataSource<Employee> eds = new EntityDataSource<Employee>(queryCriteria);
childDialogBean.showEntityList(Employee.class, eds, false);
By default, a dialog is modal. To create non-modal dialog,
DialogView dialogView = dialogBean.getViewConfig().getDialogView(true);
dialogView.setModal(false);
DialogListener dialogListener = new DialogListener() {
@Override
public PageNavigation dialogClosed(DialogBean dialogBean, Object data) throws SystemException {
// handle event
return null;
}
};
dialogBean.setDialogListener(dialogListener);
PersistenceEntityManager peManager = getPersistenceEntityManager();
Employee employee = peManager.getEntity(Employee.class, "123");
EntityDataSource eds = new EntityDataSource(employee);
return dialogBean.showEntity(Employee.class, eds, null, false);
A dialog can be closed by user on client side, or close it on server side.
To close dialog explicitly on server side and notify the listener,
dialogBean.close(true, data);
The data will be passed to the dialog listener.
containerBean.showConfirmDialog(title,
messages, commands, commandVisibleNames,
dialogBean);
After the confirm dialog is closed, the following methods
can be used to check which command is clicked.
dialogBean.getConfirmCommandClicked();
dialogBean.isConfirmed();
containerBean.showMessageDialog(title, messages);
containerBean.showProgressDialog(menuNode, initialValue,
labelTemplate, ajax,
displayOnly, closeDialogOncomplete);
see Javadoc for details.