org.araneaframework.core.util
Class ComponentUtil

java.lang.Object
  extended byorg.araneaframework.core.util.ComponentUtil

public abstract class ComponentUtil
extends Object

This utility class handles listening of component lifecycle events. Thus, it is possible to write a component (the listener) that, for example, modifies the child Environment of a component (the target).

Its usage is quite simple:

pushGlobalEnvEntry(entryId, envEntry);
 
 BaseWidget listenerComp = new BaseWidget() {
 
   protected void destroy() throws Exception {
     popGlobalEnvEntry(entryId);
   }
 
 };
 ComponentUtil.addListenerComponent(targetComp, listenerComp);
In the example above, it uses the lifecycle listener to remove an Environment entry that was added before.

Author:
Jevgeni Kabanov (ekabanov at araneaframework dot org)

Field Summary
static String LISTENER_KEY
          The request key prefix that will be used to identify the listeners invoked.
 
Constructor Summary
ComponentUtil()
           
 
Method Summary
static void addListenerComponent(ApplicationComponent target, Component listener)
          This method will attach the listener component to the target custom component, allowing it to receive all the lifecycle events (which exactly depends on the target component type).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LISTENER_KEY

public static final String LISTENER_KEY
The request key prefix that will be used to identify the listeners invoked. Prior to 1.0.2 this constant contained illegal characters (dots), thus using addListenerComponent broke component name scoping.

See Also:
Constant Field Values
Constructor Detail

ComponentUtil

public ComponentUtil()
Method Detail

addListenerComponent

public static void addListenerComponent(ApplicationComponent target,
                                        Component listener)
This method will attach the listener component to the target custom component, allowing it to receive all the lifecycle events (which exactly depends on the target component type). The listener component may never get to do something more than processing lifecycle events.

This allows for instance to add a child component that will execute some action on destroy, thus essentially tying some action to the lifecycle of the target component. A typical application is to scope something (e.g. environment entry) with the target component.

This method also handles initialization of the listener.

Parameters:
target - The component that wants to have the new listener.
listener - The listener component that will be added as a child component of the target.