myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jing Wu <jing.x...@oracle.com>
Subject [TRINIDAD] [API] [TRINIDAD-2398] add component tracking ability to RequestContext
Date Fri, 12 Jul 2013 19:12:16 GMT
Hi,

Please review the following API proposal for adding component tracking 
ability to RequestContext

[TRINIDAD] [API] [TRINIDAD-2398] add component tracking ability to 
RequestContext
https://issues.apache.org/jira/browse/TRINIDAD-2398

Requirement:

There are cases where we need to know which component is under 
processing. This can be achieved if we maintain component stack in 
RequestContext and provide API to push/pop/peek the component stack. 
Components are pushed/popped when they are decoded, validated, rendered, 
visited, etc.

For performance reason, we would like to have VisitContext keep a 
reference to the current RequestContext.

New API Proposed:

3 new methods added to RequestContext for component tracking ability. 
Default implementation is to do nothing. The methods are not abstract 
for backward compatibility reason.

   /**
    * Push the component onto the stack so we know the current component 
being processed.
    * @param context the FacesContext for the current request
    * @param component an UIComponent object to be pushed as current 
component.
    * @exception NullPointerException if <code>component</code> is null.
    * @see popCurrentComponent(FacesContext, UIComponent) and 
getCurrentComponent()
    */
   public void pushCurrentComponent(FacesContext context, UIComponent 
component)
   {
     return;
   }

   /**
    * Pop the component out from the stack.
    * @param context the FacesContext for the current request
    * @param component an UIComponent object to be poped.
    * @exception IllegalStateException if <code>component</code> is not 
the same
    * as the current top component in the component stack.
    * @see pushCurrentComponent(FacesContext, UIComponent) and 
getCurrentComponent()   */
   public void popCurrentComponent(FacesContext context, UIComponent 
component)
   {
     return;
   }

   /**
    * Returns the current component being processed.
    * @see pushCurrentComponent(FacesContext, UIComponent) and 
popCurrentComponent(FacesContext, UIComponent)
    */
   public UIComponent getCurrentComponent()
   {
     return null;
   }


2. New method added to VisitContext to retrieve RequestContext instance. 
Subclasses can hold a reference to the current RequestContext instance 
and return that reference.

   /**
    * <p>Returns the RequsetContext instance for the current request.</p>
    */
   public RequestContext getRequestContext()
   {
     return RequestContext.getCurrentInstance();
   }


Thanks,
Jing


Mime
View raw message