3, use components in Webwork
Based on the component implementation of XWork, WebWork is based on the component implementation of the component object, so that these components are valid for the Action class.
There are two types of classes in WebWork to use Enabler interfaces: Action, and components. To enable Action to set the components they need, it must be valid for ComponentInterceptors; the same is true for components.
(1) Life cycle range
In WebWork, components can be configured to three ranges:
l Single request (Request)
l User Session (Session)
l Whole Application (Application)
Webwork is lagging after loading components. That is, no matter which range, the components are initialized when used, destroyed at the end of the life cycle of the specified range. For example, an application range is initialized when the user first requests the enabler interface of the component's enabler interface, and it is destroyed at the end of the application.
Since one component is allowed to depend on another component, the component cannot rely on components than its range. For example, components of the user session range cannot depend on components of the request range.
Alternatively, all components must be registered in Components.xml (see the configuration chapter after see).
(2) Get ComponentManager
In any request, there are three ComponentManager instances, corresponding to each range. The instance is saved in the attribute called DEFAULTCOMPONENTMANAGER in the corresponding range. Below is an example of obtaining ComponentManager with a request range:
ComponentManager cm = (ComponentManager) Request.getaTribute ("defaultComponentManager);