Embedded Objects - Exec

To execute one or more command after an embedded object is created and before added to a region, add one or more

	<exec action="menuNode-command-or-id" />
under the <object> element.

The action attribute value is the command name or id of a menu node. For example, cmd.Search, id.DoSomething.

Note that the menu node must exist in a MenuBean, the header menu or footer menu of an EntityBackingBean or EntityListBackingBean. Otherwise, the action will be ignored with a warning message.

For example, embed a query form in region 8, and show query results in region 9 at the same time.


<object xmlns="http://www.cmobilecom.com/af/objects"
        id="queryEmployees" type="entity" region="8">
  	<entityType>ExampleHR.EMP</entityType>
	<viewConfig>
		<viewType>QUERY</viewType>
    	
		<viewConfig name="footerMenu" >
			<viewType>MENU</viewType>
			<menuStyle>LIST</menuStyle>
			<menuNode key="cmd.Search">
				<partialBehaviorSupport>
					<partialBehavior event="action">
						<renderRegions>9</renderRegions>
						<openDialog>false</openDialog>
					</partialBehavior>
				</partialBehaviorSupport>
			</menuNode>
		</viewConfig>
	</viewConfig>
	
	<exec action="cmd.Search"/>
</object>

<object xmlns="http://www.cmobilecom.com/af/objects"
        id="employees" type="placeholder" region="9">
</object>

To hide the query form and show its query results only in the same region, add

	<hidden>true</hidden>
under the <object> element.

<object xmlns="http://www.cmobilecom.com/af/objects"
        id="queryEmployees" type="entity" region="8">
  	<entityType>ExampleHR.EMP</entityType>
	<viewConfig>
		<viewType>QUERY</viewType>
    	
		<viewConfig name="footerMenu" >
			<viewType>MENU</viewType>
			<menuStyle>LIST</menuStyle>
			<menuNode key="cmd.Search">
				<partialBehaviorSupport>
					<partialBehavior event="action">
						<renderRegions>8</renderRegions>
						<openDialog>false</openDialog>
					</partialBehavior>
				</partialBehaviorSupport>
			</menuNode>
		</viewConfig>
	</viewConfig>
	
	<exec action="cmd.Search"/>
	<hidden>true</hidden>
</object>
The query form can be opened from the query results to narrow search or change query criteria.

Another example, show Expense Report in region 8, group by employee and set chart width to be 400px.


<object xmlns="http://www.cmobilecom.com/af/objects"
        id="expenseReport" type="entity" region="8">
  	<entityType>ExampleHR.ER</entityType>
	
	<criteriaElements>
		<function name="EQ" property="groupBy">0</function>
		<function name="EQ" property="chartWidth">400</function>	
	</criteriaElements>
	
	<viewConfig>
		<viewType>QUERY</viewType>
    	
		<viewConfig name="footerMenu" >
			<viewType>MENU</viewType>
			<menuStyle>LIST</menuStyle>
			<menuNode key="cmd.View">
				<partialBehaviorSupport>
					<partialBehavior event="action">
						<renderRegions>8</renderRegions>
						<openDialog>false</openDialog>
					</partialBehavior>
				</partialBehaviorSupport>
			</menuNode>
		</viewConfig>
	</viewConfig>
	
	<exec action="cmd.View"/>
	<hidden>true</hidden>
</object>
ExampleHR.ER is mapped to ExpenseReportQueryForm. Create the query form bean and then execute the View command to generate the report in the same region 8. The query form beean is hidden, which can be opened from report bean to change report data and display options.