Cmobilecom AF 5.19 Developer Guide

22 Extensions

EntityProperty, render style and view components can be extended.

Entity Property

To add a new type of EntityProperty, extend EntityProperty or one of its subclasses 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)
MyEntityProperty objects can also be created dynamically and added to EntityBackingBean or EntityListBackingBean.

Render Style and View Component

To add a new view component type, a style number must be specified. A style number is mapped to a view component type (one to one). Style numbers from 1 to 500 are reserved. For example, Add render style for view component ColorPicker.
	public static final int RENDER_STYLE_COLOR_PICKER = 501;
Style numbers can be used in property annotations. For example,

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

	RenderStyle renderStyle = new RenderStyle(RENDER_STYLE_COLOR_PICKER);
For web, add the new JSF ColorPicker component in the file "include/property.xhtml" inside cmobilecom-af-<version>.war under ${CMOBILECOM_AF_DIR}/installer. For example, add PrimeFaces colorPicker component:

<ui:composition>
	...

	<f:facet name="style_501">
		<p:colorPicker value="#{property.valueString}" >
			<p:ajax process="#{property.partialBehaviorSupport['change'].executeString}" event="change"
				disabled="#{(empty property.partialBehaviorSupport['change']) || property.partialBehaviorSupport['change'].disabled}"
				partialSubmit="true"
				listener="#{property.uiView.handleAjaxBehaviorEvent}" />
		</p:colorPicker>
	</f:facet>
    
</ui:composition>    
Note that the facet name is "style_" followed by style number. property is EntityProperty variable that can be bound to UI component attributes. For example,


	<f:facet name="style_502">
		<my:myComponent value="#{property.valueInteger}" 
			action="#{property.actionMethod}" />
	</f:facet>
   
The EntityProperty using the style number must define getter/setter of valueInteger and method actionMethod.
Embedded Objects: Text FileWeb ResourcesFrames / No Frames