Extensions

Cmobilecom AF can be customized or extended if needed.

Page Content and Layout

Page content and layout are defined in [CMOBILECOM.HOME]/conf/containers.xml. For example, adding east layout unit with region 7 and 8 to the manage page.

	<pageLayout type="border">
		...
		<unit position="east">
			<resizable>true</resizable>
			<content>#{region_7}#{region_8}</content>			
		</unit>
	</pageLayout>

Container Bean

ContainerBean can be extended to add page content for GET method, and used in a page. The container bean needs to process request parameters if supported.

@ManagedBean(name="myCntrBean")
@ViewScoped
public class MyContainerBean extends ContainerBean {
	
	@Override
	@PostConstruct
	protected void init() {
		super.init();
			
	  	FacesContext facesContext = FacesContext.getCurrentInstance();
	  	if (facesContext.isPostback())
	  		return;
	  	
		// GET request: add page content
	}
}
The container bean can be used in a page using facelet templating. For example, mypage.xhtml that uses myCntrBean and add mypage.css resource in the head section.

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

<ui:composition template="/include/pageLayout.xhtml"> 

<ui:param name="containerBean" value="#{myCntrBean}" /> 

<ui:define name="resources">
	<h:outputStylesheet library="com.mycompany" name="themes/mypage.css" target="head"/>
</ui:define>
	
</ui:composition>
</html>	

Entity Property

To add a new type of EntityProperty, extend EntityProperty or one of its subclass and define the following constructor:

public class MyEntityProperty<T extends PersistenceEntity> 
extends EntityProperty<T> {

  	public MyEntityProperty(PersistenceDataBackingBean<T> backingBean, String name, Class type,
		Method readMethod, Method writeMethod, EntityProperty<T> parent) throws SystemException {
		super(backingBean, name, type, readMethod, writeMethod, parent);
	}
}
MyEntityProperty can be used in property annotations:

	@Property(name="foo", entityPropertyType=MyEntityProperty.class)

Render Style

To create a render style, a style number must be specified. A style number is mapped to a facet of UI components. Style numbers from 1 to 500 are reserved by system. If a new style number, 501, for example, can be used in a property annotation like:

	@Property(name="foo",
		renderStyle=@RenderStyleDef(style=501))
or in a RenderStyle object:

	RenderStyle renderStyle = new RenderStyle(501);
then the facet for the style number must be added into the include/property.xhtml in the war.

<ui:composition>
	...
	<f:facet name="style_501">   
		// JSF UI components
	</f:facet>
    
</ui:composition>    
Or define propertyExtensions in a page if the style is used by the page only. For example,

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

<ui:composition template="/include/pageLayout.xhtml"> 

<ui:param name="containerBean" value="#{myCntrBean}" /> 

<ui:define name="resources">
	<h:outputStylesheet library="com.mycompany" name="themes/mypage.css" target="head"/>
</ui:define>


<ui:define name="propertyExtensions">
	<f:facet name="style_501">   
		// JSF UI components
	</f:facet>
</ui:define>

	
</ui:composition>
</html>	

property is the variable that can be bound to UI component attributes. For example,


	<f:facet name="style_501">   
		<my:myComponent value="#{property.valueInteger}" 
			action="#{property.actionMethod}" />
	</f:facet>
   
The EntityProperty using the style number 501 must define getter/setter of valueInteger and method actionMethod.

Style numbers should be defined as constants. For example,


	public static final int STYLE_FOO = 501;
	public static final int STYLE_BAR = 502;