Cmobilecom AF 5.19 Developer Guide

6.1 ContainerBean

A ContainerBean has a page content that consists of regions, and each region holds a list of beans. For example,

	ContainerBean containerBean = ;
	PageContent pageContent = containerBean.getPageContent();
	Region region = pageContent.getRegion(0);
	List<BackingBean> beans = region.getBeanList();
A ContainerBean can have a child ContainerBean(DialogBean), and a DialogBean can have a child DialogBean. For example,

	ContainerBean containerBean = ;
	DialogBean dialogBean = containerBean.getDialogBean();
	PageContent dialogPageContent = dialogBean.getPageContent();
	
	DialogBean childDialogBean = dialogBean.getDialogBean();
	ContainerBean parent = childDialogBean.getContainerBean();
	ContainerBean root = childDialogBean.getRootContainerBean();

A root ContainerBean is a ViewScoped managed bean. By default there are three pages and three root ContainerBeans accordingly.

These managed beans can be used in EL expressions in their page containers or in pages. For example, check if user is logged in:

#{empty containerBean.backingBeanContext.authenticatedUser}

A root ContainerBean can have a main menu(called ContainerMenuBean), page header menu and/or toolbar.

Page Border Layout

Page loyout is a border layout. Layout unit positions are north, west, center, east and south. Within a layout unit, layout code can be added which is a HTML code containing expressions. For example, the center layout unit content is #{region_5}#{region_6}, which means the layout unit contains region 5 and region 6.

See ContainerBean Configuration for detail.

Region Layout

How to layout beans within a region? Region layout can be FLOW, TAB_VIEW, GRID, COLUMN_VIEW, or LAYOUT_CODE. Default layout type is FLOW, which means that beans within a region are flowing from left to right and from top to bottom.

For example, to change layout type to 2 columns,


	Region region = pageContent.getRegion(regionNumber);
	region.setLayoutType(LayoutType.COLUMN_VIEW);
	region.setLayoutColumns(2);
To use layout code with embedded EL expressions:

	Region region = pageContent.getRegion(regionNumber);
	region.setLayoutType(LayoutType.LAYOUT_CODE);
	String layoutCode = "<div>#{bean_0}</div><div>#{bean_1}</div>";
	region.setlayoutCode(layoutCode);
#{bean_N} will be resolved to the bean at position N within the region.

View Info

View Info stores the information about a view when it is started by the first page of the view which is requested by GET method. A view has a request URI and parameters of its initial page, and the parameters are called view parameters. Post will not change view parameters.

For example,

     GET /contextPath/page/page1?p1=v1&p2=v2
     POST /contextPath/page/page1
     POST /contextPath/page/page1
Context path is /contextPath, request URI is /page/page1, and view parameters are: p1=v1, p2=v2.

message, locale, _sid are not view parameters.

Note that the viewInfo is stored before any URL rewriting is applied.

View Info is used to create bookmarkable URLs. See Bookmarkable URL for detail.

Saving States

Container beans such as indexCntrBean and manageCntrBean are ViewScoped. A new instance will be created for a page requested with GET method. The max number of pages saved can be configured in web.xml.

	<context-param>
		<param-name>com.sun.faces.numberOfViewsInSession</param-name>
		<param-value>5</param-value>
	</context-param>

	<context-param>
		<param-name>com.sun.faces.numberOfLogicalViews</param-name>
		<param-value>10</param-value>
	</context-param>
Saving states is disabled for bots(search engines) to save resources. See ${cmobilecom.home}/conf/user-agent.xml for bot configuration. If request parameter saveStates=false, saving states will be disabled. But saveStates=true will be ignored.

Saving states should be disabled for pages that does not have any POST actions.

Entity ManagerDialogFrames / No Frames