Cmobilecom AF 5.19 Developer Guide

21.2 Embedded Objects - Rendered Condition

An object can be embedded conditionally using the attribute rendered whose value is a JSF EL expression. For example,

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="objectId" type="objectType"
			rendered="#{!containerBean.backingBeanContext.authenticatedUser}">
	</object>
where containerBean is current page ContainerBean.

An embedded object with object id objectFoo can be referenced to by #{containerBean.embeddedObjects.objectFoo}. For example,


	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="objectId" type="objectType"
			rendered="#{empty containerBean.embeddedObjects.objectFoo.entity}">
	</object>
requestScope is used to access request parameters or attributes in EL expressions. For example,

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="objectId" type="objectType"
			rendered="#{requestScope.paramName > 10}">
	</object>
Example: show the Employee for current user, or create new one if it does not exist.

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="showEmployee" type="entity">

		<entityType>HR.EMP</entityType>
		<mode>VIEW</mode>

		<criteriaElements>
			<function name="EQ" property="user">#{current_user}</function>
		</criteriaElements>

		<viewConfig>
			<viewType>ENTITY</viewType>

			<!-- entity not found: ignore to return null object,
				and the object createEmployee will be shown -->
			<param name="entity.not.found"  value="ignore" />
		</viewConfig>
	</object>

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="createEmployee" type="entity"
			rendered="#{empty containerBean.embeddedObjects.showEmployee.entity}">

		<entityType>HR.EMP</entityType>
		<mode>CREATE</mode>

		<properties>
			<property name="user">#{current_user}</property>
			<property name="name">#{current_user.name}</property>
		</properties>

		<viewConfig>
			<viewType>ENTITY</viewType>
		</viewConfig>
	</object>
Embedded Objects: OverviewEmbedded Objects: RegionFrames / No Frames