The component element executes a method within a component or sets property and outputs values from a component to the output ModelMap. It can also resolve a component or invoke a method on a component.

The component element contains the following:




Identifies the Nucleus path of the component.


(Optional) Identifies the name of the method to be executed. Use only when invoking a method.


Provides a variable name that accesses the component’s properties.


Identifies the variable name that accesses the method invocation’s returned value.


This attribute defines the actor ID, and is used for actor ordering.


By default, all set-property values require session confirmation numbers. This property is set to true by default.


By default, all method calls require session confirmation numbers. This property is set to true by default.


This element defines actors that must be executed prior to the execution of the current actor. There can be multiple depends elements associated with an actor.


This element defines actors that, if present, must be executed prior to the execution of the current actor. There can be multiple depends-if-present elements associated with an actor


This element defines each actor’s input. Actors can have multiple input elements.


This element defines each actor’s output. Output elements create a map entry in a ModelMap. Actors can have multiple output elements.

Example: Resolving a Component

The following example resolves a component that sends output from the properties of the component to a ModelMap. In this example, the component class instance is saved in the shoppingCart variable of the ActorContext.

<component id="shoppingCart" name="/atg/commerce/ShoppingCart"
    component-var="shoppingCart" >
  <output name=orderId" name="orderId" value="${}"/ >

Note that you can reference a component without having to invoke a component actor. The following example shows how you would resolve the orderID component in-line. This works for components that are referenced only once; if you plan to reference the same component multiple times, it is best to define the variable, as in the above example:

<input name="ordered" value="${nucleus['/atg/userprofiling/
Example: Executing a Method

You can also use the component element to execute a method on a Nucleus component. The following example shows how the return value is stored in the orderStatus variable and stores the method return value into the ModelMap under the orderStatus key.

<component id="orderStatus" name="/atg/commerce/order/OrderServices"
    method="getOrderStatus" component-var="orderService"
  <input name="viewOrderId" value="${param.orderId}" />
  <output name="orderStatus" value="${orderStatus}" />
Example: Finding a Method using a String Array

You can also use the component element to find a method by providing a string array. For example, to find a method that contains a string array, such as atg.commerce.order.OrderLookupService.
, you must provide the String and String[] class-names. In the following example, the String[] is passed in as [Ljava.lang.String; and passed to the getOrderCount method.

<component id="orderLookupService" name="/atg/commerce/order/OrderLookupService"
    method="getOrderCount" method-return-var="numberOfOrders">
  <input name="profile" class-name="java.lang.String"
      value="${profile.repositoryId}" />
  <input name="closedStates" class-name="[Ljava.lang.String;"
      value="$nucleus['/atg/commerce/order/OrderLookup'].closedStates" />
Example: Finding a Method Using an Interface

You can use the component element to find a method if the method has an interface signature. For example, the atg.commerce.pricing.PricingTools.priceOrderSubtotal(Order, Locale,
RepositoryItem, Map)
method needs the interface class-names:

<component id="pricingTools" name="/atg/commerce/pricing/PricingTools"
  <input name="order" class-name="atg.commerce.order.Order" index="0"
  <input name="locale" class-name="java.util.Locale" index="1"
  <input name="profile" class-name="atg.repository.RepositoryItem" index="2"
  <input name="parameters" class-name="java.util.Map" index="3" value="${null}"/>
Example: Finding a Method using Generics

If you are using a method that contains a generic class or interface, use the component element to provide the necessary type parameters. For example, to find the atg.multisite.SiteGroupManager.
filterInactiveSites (Collection<Site>)
method, you would create the following:

<component id="siteGroupManager" name="/atg/multisite/SiteGroupManager"
    method="filterInactiveSites" component-var="siteGroupManager "
  <input name="sites" class-name="java.util.Collection"
      value="${objectParam.sites}" />
  <output id="sites" name="sites" value="${sites}" />
Example: Using Primitives When Executing Methods

The REST MVC framework accepts the use of primitive data types. The following example shows how a boolean primitive data type is identified using a primitive type name in class-name:

<component id="siteManager" name="/atg/multisite/SiteManager"
   method="getSitesByState" component-var="siteManager" method-return-var="sites">
  <input name="active" class-name="boolean" value="${}" />
  <output id="sites" name="sites" value="${sites}" />
Example: Using Primitive Arrays When Executing Methods

You can use an array of primitive data types to return method information. The following example shows how a boolean primitive array is used:

<component id="myComponent" name="/custom/MyComponent"
   method="getOrders" component-var="myComponent" method-return-var="orders">
  <input name="flags" class-name="[Z" value="${objectParam.flags}" />
  <output id="orders" name="orders" value="${orders}" />

Note that the following class-name values are used to identify primitive array types:

Primitive Data Array Type

Class-Name Value


[C for example, class-name="[C"


[S for example, class-name="[S"


[D for example, class-name="[D"


[J for example, class-name="[J"


[Z for example, class-name="[Z"


[B for example, class-name="[B"


[F for example, class-name="[F"


[I for example, class-name="[I"

Example: Passing Multiple Arguments

To pass more than one argument into a method, you must specify the index attribute on the inputs so that the input arguments for the method are ordered. For complex object types, you may need to convert the string value to an object by specifying a PropertyEditor or TagConverter. Any registered property manager can be used to convert inputs into complex object types so that they may pass method parameters. The system attempts to coerce the input value to the correct type of object based on the method’s expected input type. If the method is overloaded, you may need to specify the PropertyEditor to disambiguate between the overloaded methods. Also, it is usually necessary to define a PropertyEditor for collections of complex objects since the type of objects contained in the collection cannot be determined at run time.

<component id="methodEx" name="/my/component/Example" method="doSomething"
    component-var="example" method-return-var="rtn">
  <!-Fictitious DateListPropertyEditor that converts pDateRange into a list of
     dates -->
  <input name="pDateRange" value="${param.dateRange}" index="0"
  <!-We did not need to specify the ProperyEditor but we could specify
       atg.nucleus.PropertyEditors.LocalePropertyEditor -->
  <input name="pLocale" value="${param.locale}" index="1"/>
Example: Setting Property Values

The following is an example of setting property values on a Nucleus component. The ComponentActor sets the listId property value and outputs the currentList property value:

  <component id="paymentFroupFormHandler"
    <input name="listId" value="${param.listId}" priority="1000" />
    <output id="currentList" name="currentList"
        value="${paymentGroupFormHandler.currentList}" />
Example: Disabling Component Actor Dynamo Session Confirmation Numbers

Important: The following information is for use within development environments only. Dynamo session confirmation numbers provide session security and must be enabled in production environments.

By default ComponentActors use Dynamo session confirmation numbers, _dynSessConf, for method calls and setting property values. However, session confirmation numbers are not required for calls such as outputting properties of a component, a JSPActor or a DropletActor. For detailed information on Dynamo Session Confirmation Numbers, refer to the ATG Platform Programming Guide.

The following example shows how to disable session confirmation numbers for method calls:

<component id="orderStatus" name="/atg/commerce/order/OrderServices"
    method="getOrderStatus" component-var="orderService"
  <input name="viewOrderId" value="${param.orderId}"
      class-name="java.lang.String" />
  <output id="orderStatus" name="orderStatus" value="${orderStatus.state}" />

The following example shows how to disable set property values:

<component id="salesChannel" name="/atg/commerce/order/OrderServices"
  <input name="viewOrderId" value="contactCenter"
      class-name="java.lang.String" />
  <output id="orderStatus" name="salesChannel"
      value="${orderService.salesChannel} " />

Note that the /atg/dynamo/service/actor/Configuration.enforceSessionConfirmation flag can be used to disable this requirement during development. It is recommended that this flag is disabled only in your development environment.

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices