Cmobilecom AF 5.19 Developer Guide

6.2 Dialog

DialogBean is a ContainerBean and has a pageContent with regions. Its content and layout can be configured in conf/containers.xml. By default, it has three regions: 0, 1, 2. Region 0 for query, region 1 for query results, and region 2 for multiple entity selections. Its default configuration is:

<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);

Dialog Listener

A dialog listener will be notified when the dialog is closed.

    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.

Confirm Dialog

To open a confirm dialog from a containerBean:

    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();

Message Dialog

To open a message dialog from a containerBean:

    containerBean.showMessageDialog(title, messages);

Progress Dialog

To open a progress dialog from a containerBean:

    containerBean.showProgressDialog(menuNode, initialValue,
            labelTemplate, ajax,
            displayOnly, closeDialogOncomplete);
see Javadoc for details.
Container BeanEntity Backing BeanFrames / No Frames