public final class ActiveComponentContext extends Object
Called by Renderers that want to support active data on their attributes. The current instance
is retrieved by calling the factory method
ActiveComponentContext.getActiveComponentContext().
A Renderer that wishes to support active data on its attributes should:
pushActiveComponent with its component before retrieving any attributes.
Before fetching each component attribute for which active data will be supported, call
startActiveAttribute and then call endActiveAttribute after the
value has been retrieved.
popActiveComponent after all of the active attributes have been retrieved.
If any of the potentially active attributes were bound to ActiveDataModels,
popActiveComponent will register an ActiveDataEncoder for the component.
| Modifier and Type | Method and Description |
|---|---|
void |
endActiveAttribute(String attributeName)
Removes the association of active data with the attributeName component attribute.
|
static ActiveComponentContext |
getActiveComponentContext()
Returns an instance of the ActiveComponentContext for use by a component that wants to support
active data on its attributes.
|
boolean |
hasActiveData()
Returns
true if the currently pushed active component currently has associated
active data. |
boolean |
mayHaveActiveData()
Returns
true if the currently pushed active component may have associated
active data. |
javax.faces.component.UIComponent |
peekComponent() |
void |
popActiveComponent(javax.faces.context.FacesContext context,
org.apache.myfaces.trinidad.context.RequestContext requestContext,
javax.faces.component.UIComponent component)
Stops associating active data with this component, registering an appropriate
ActiveDataEncoder with any ActiveDataModels providing active data for the active
attributes.
|
void |
popActiveComponent(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
Deprecated.
Use
RequestContext.popCurrentComponent(FacesContext, UIComponent) instead. |
void |
popEditableValueComponent(javax.faces.component.UIComponent component)
Pop the editable component from the stack.
|
void |
pushActiveComponent(javax.faces.context.FacesContext context,
org.apache.myfaces.trinidad.context.RequestContext requestContext,
javax.faces.component.UIComponent component)
Deprecated.
Use
RequestContext.pushCurrentComponent(FacesContext, UIComponent) instead. |
void |
pushActiveComponent(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
Deprecated.
Use
RequestContext.pushCurrentComponent(FacesContext, UIComponent) instead. |
void |
pushEditableValueComponent(javax.faces.component.UIComponent component)
Push the editable component on the top of the stack.
|
void |
release()
This method reset the current ActiveComponentContext instance, and it detach the thread local.
|
void |
startActiveAttribute(String attributeName)
Sets the name of the component attribute that any EL references to ActiveDataModels should
be associated with until the corresponding
cleatActiveAttribute is called. |
void |
startSupressingActiveComponents()
Deprecated.
use startSupressingActiveComponents(boolean) instead
|
void |
startSupressingActiveComponents(boolean hasActiveData)
Called by Renderers that perform their own active component management to disable the
generation of the mapping between components and ActiveDataModels on the current
component and its children.
|
void |
stopSupressingActiveComponents()
Called by Renderers that perform their own active component management to disable the
generation of the mapping between components and ActiveDataModels.
|
public static ActiveComponentContext getActiveComponentContext()
public void startSupressingActiveComponents()
startSupressingActiveComponents
may be nested.IllegalStateException - if there are no current active components on the stack,
or if the instance if already releasedstopSupressingActiveComponents()public void startSupressingActiveComponents(boolean hasActiveData)
startSupressingActiveComponents
may be nested.hasActiveData - if the component has active data.IllegalStateException - if there are no current active components on the stack,
or if the instance if already releasedstopSupressingActiveComponents()public void stopSupressingActiveComponents()
IllegalStateException - if active data mapping collection isn't currently suppressed,
or if the instance is already releasedstartSupressingActiveComponents(boolean)public void pushActiveComponent(javax.faces.context.FacesContext context,
org.apache.myfaces.trinidad.context.RequestContext requestContext,
javax.faces.component.UIComponent component)
RequestContext.pushCurrentComponent(FacesContext, UIComponent) instead.
In order to avoid mismatched pushActiveComponent/popActiveComponent
pairs if an exception occurs when fetching the attribute value, try/
finally should be used:
protected void encodeAll(
FacesContext context,
RenderingContext rc,
UIComponent component,
ClientComponent client,
FacesBean bean
) throws IOException
{
ActiveComponentContext activeContext = ActiveComponentContext.getActiveComponentContext();
activeContext.pushActiveComponent(context, component);
try
{
super.encodeAll(context, rc, component, client, bean);
}
finally
{
activeContext.popActiveComponent(context, component);
}
}
context - FacesContext of this requset.requestContext - RequestContext of this request.component - UIComponent to begin associating active data withIllegalStateException - if the instance is already releasedNullPointerException - if context or component are null.IllegalStateException - if component is not the current component on the requestContext.popActiveComponent(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RequestContext, javax.faces.component.UIComponent)public void pushActiveComponent(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
RequestContext.pushCurrentComponent(FacesContext, UIComponent) instead.context - FacesContext of this requset.component - UIComponent to begin associating active data withNullPointerException - if context or component are null.IllegalStateException - if component is not the current component on current RequestContext.popActiveComponent(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RequestContext, javax.faces.component.UIComponent)public javax.faces.component.UIComponent peekComponent()
public void startActiveAttribute(String attributeName)
Sets the name of the component attribute that any EL references to ActiveDataModels should
be associated with until the corresponding cleatActiveAttribute is called.
In order to avoid mismatched setActiveAttribute/clearActiveAttribute
pairs if an exception occurs when fetching the attribute value, try/
finally should be used:
ActiveComponentContext activeContext = ActiveComponentContext.getActiveComponentContext();
// support active data for the source attribute
activeContext.startActiveAttribute("source");
String srcURI;
try
{
srcURI = super.getSource(bean);
}
finally
{
// done with the source attribtue
activeContext.endActiveAttribute("source");
}
Any attribute that supports active data should have an optimized client-side setter
attributeName - Name of component attribute to associate active data with.IllegalStateException - if pushActiveComponent hasn't been called or
there is already an attribute active on this component, or if the instance is already released.IllegalArgumentException - if attributeName is null
attribute is currently started.endActiveAttribute(java.lang.String),
pushActiveComponent(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RequestContext, javax.faces.component.UIComponent)public void endActiveAttribute(String attributeName)
attributeName - Name of component attribute to stop associating active data withIllegalStateException - if the cleared attribute doesn't match the currently set
attribute or the instance is already released.NullPointerException - if attributeName is null.startActiveAttribute(java.lang.String)public boolean hasActiveData()
true if the currently pushed active component currently has associated
active data.true if the currently pushed active component currently has associated active data.IllegalStateException - if the instance is already releasedmayHaveActiveData()public boolean mayHaveActiveData()
true if the currently pushed active component may have associated
active data. This can occur if the component appears inside an ancestor that is suppressing
active data, but has associated active data of its own that may apply to the componenttrue if the currently pushed active component may have associated active data.IllegalStateException - if the instance is already releasedhasActiveData()public void popActiveComponent(javax.faces.context.FacesContext context,
org.apache.myfaces.trinidad.context.RequestContext requestContext,
javax.faces.component.UIComponent component)
context - Current FacesContextrequestContext - the request context.component - UIComponent to stop associating active data withIllegalStateException - if the cleared attribute doesn't match the currently set
attribute or the instance is already released.NullPointerException - if attributeName or
attributeEncoder are null.pushActiveComponent(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RequestContext, javax.faces.component.UIComponent)public void popActiveComponent(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
RequestContext.popCurrentComponent(FacesContext, UIComponent) instead.context - Current FacesContextcomponent - UIComponent to stop associating active data withIllegalStateException - if the cleared attribute doesn't match the currently set
attribute.NullPointerException - if attributeName or
attributeEncoder are null.pushActiveComponent(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RequestContext, javax.faces.component.UIComponent)public void release()
public void pushEditableValueComponent(javax.faces.component.UIComponent component)
value attribute of a component.
In order to avoid mismatched pushEditableValueComponent/popEditableValueComponent
pairs if an exception occurs in between try/, finally should be used.
component - UIComponent to be pushed on the stack.NullPointerException - if component is null.popEditableValueComponent(javax.faces.component.UIComponent)public void popEditableValueComponent(javax.faces.component.UIComponent component)
value attribute of a component is done.component - UIComponent to be poped.IllegalStateException - if components are not paired properly.NullPointerException - if component is null.pushEditableValueComponent(javax.faces.component.UIComponent)