The bean
element defines a filter for a Java bean class or interface that is in the ModelMap
. The filter can be defined at any level of the class and interface hierarchy, and will automatically apply classes and interfaces that have a filter with the same ID. Note that it is best to insert whole objects into the ModelMap
and allow bean filtering to control the way that the object is viewed. By defining a filter for every object you can control the output for that object.
The bean
element contains the following attributes:
Attribute | Description |
---|---|
| The fully qualified package name of the class or interface. |
| The ID of the default filter. If no |
Available Filters
There are three filters that are primarily used:
detailed
– This filter provides a detailed listshort
– This filter provides a short listsummary
– This filter provides a summary
The following is an example of the ElectronicShippingGroup
filter:
<bean type="atg.commerce.order.ElectronicShippingGroup> <filter id="summary"> <property name="emailAddress"/> <property name="shippingAddress"/> </filter> </bean>
If the same property is defined in the super and sub-class, the subtype definition overrides the super-type property definition if both reference the same filter ID. If filters are defined on two interfaces that a Java servlet bean implements, but no filter is defined on the classes that the bean implements, the output from both interface filters will be included.
Working with Shared Properties
The bean
element allows you to define properties that are shared in one filter and then reference the filter class by super-type. For example, the ElectronicShippingGroup
and the HardgoodShippingGroup
are similar. However, the ElectronicShippingGroup
adds the emailAddress
property and does not require the ShippingAddress
property. In the following example, the majority of the properties have been moved to the super-type class ShippingGroup
. Because the HardgoodShippingGroup
contains all of the properties of the based ShippinGroup
, it does not need a definition. The ElectronicShippingGroup
defines the emailAddress
property and hides the unneeded shippingAddress
property.
Note: Combining all shipping groups within one filter is not recommended, the following is merely an example. It is best to have a filter defined for each shipping group:
<bean type="atg.commerce.order.ShippingGroup"> <filter id="summary"> <property name="actualShipDate"/> <property name="id"/> <property name="shipOnDate"/> <property name="shippingAddress"/> <property name="shippingGroupClassType"/> <property name="shippingMethod"/> <property name="specialInstructions"/> <property name="stateAsUserResource"/> <property name="stateDetail"/> <property name="submittedDate"/> <property name="trackingNumber"/> </filter> </bean> <bean type="atg.commerce.order.ElectronicShippingGroup> <filter id="summary"> <property name="emailAddress"/> <property name="shippingAddress"/> </filter> <component> <!-- <bean type="atg.commerce.order.HardgoodShippingGroup" super-type="atg.commerce.order.ShippingGroup"/> -- > </bean>