CompositeComponentStackManager
is responsible for managing the two different composite component stacks currently used by Mojarra.
The stacks are identified by the {@link StackType} enum which has two elements,TreeCreation
and
Evaluation
.
The TreeCreation
stack represents the composite components that have been pushed by the TagHandlers responsible for building the tree.
The Evaluation
stack is used by the EL in order to properly resolve nested composite component expressions.
{
if (ve instanceof ContextualCompositeValueExpression)
{
FacesContext ctx = FacesContext.getCurrentInstance();
ContextualCompositeValueExpression ccve = (ContextualCompositeValueExpression)ve;
CompositeComponentStackManager manager = CompositeComponentStackManager.getManager(ctx);
UIComponent cc = manager.findCompositeComponentUsingLocation(ctx, ccve.getLocation());
// set Parent
return cc;
}
return null;
}
// ----------------------------------------------------- Private Methods
private boolean pushCompositeComponent(FacesContext ctx) {
CompositeComponentStackManager manager =
CompositeComponentStackManager.getManager(ctx);
UIComponent foundCc = null;
if (location != null) {
foundCc = manager.findCompositeComponentUsingLocation(ctx, location);
} else {
// We need to obtain the Location of the source expression in order
// to find the composite component that needs to be available within
// the evaluation stack.
if (source instanceof TagValueExpression) {
ValueExpression orig = ((TagValueExpression) source).getWrapped();
if (orig instanceof ContextualCompositeValueExpression) {
foundCc = manager.findCompositeComponentUsingLocation(ctx, ((ContextualCompositeValueExpression) orig).getLocation());
}
}
}
if (null == foundCc) {
foundCc = this.cc;
}
return manager.push(foundCc);
}
}
private void popCompositeComponent(FacesContext ctx) {
CompositeComponentStackManager manager =
CompositeComponentStackManager.getManager(ctx);
manager.pop();
}
// hook method
owner.onComponentCreated(ctx, c, parent);
}
CompositeComponentStackManager ccStackManager =
CompositeComponentStackManager.getManager(context);
boolean compcompPushed = pushComponentToEL(ctx, c, ccStackManager);
if (ProjectStage.Development == context.getApplication().getProjectStage()) {
ComponentSupport.setTagForComponent(context, c, this.owner.getTag());
// hook method
owner.onComponentCreated(ctx, c, parent);
}
CompositeComponentStackManager ccStackManager =
CompositeComponentStackManager.getManager(context);
boolean compcompPushed = pushComponentToEL(ctx, c, ccStackManager);
if (ProjectStage.Development == context.getApplication().getProjectStage()) {
ComponentSupport.setTagForComponent(context, c, this.owner.getTag());
// find parent
if (ve instanceof ContextualCompositeValueExpression)
{
FacesContext ctx = FacesContext.getCurrentInstance();
ContextualCompositeValueExpression ccve = (ContextualCompositeValueExpression)ve;
CompositeComponentStackManager manager = CompositeComponentStackManager.getManager(ctx);
UIComponent cc = manager.findCompositeComponentUsingLocation(ctx, ccve.getLocation());
// set Parent
parent = cc;
}
else
{ // find parent
* Walk the component tree to perform any required per-component operations.
*/
private void processTree(FacesContext context, UIComponent component) {
// For correct evaluation of #{cc.XXX} binding expressions
CompositeComponentStackManager stackManager = CompositeComponentStackManager.getManager(context);
boolean pushed = false;
if (UIComponent.isCompositeComponent(component)) {
pushed = stackManager.push(component, CompositeComponentStackManager.StackType.TreeCreation);
}
// Only resetting the valid flag in the RESTORE_VIEW phase,
// not during RENDER_RESPONSE
if (!context.getRenderResponse() && component instanceof EditableValueHolder) {
((EditableValueHolder) component).setValid(true);
}
ValueExpression binding = component.getValueExpression("binding");
if (binding != null) {
binding.setValue(context.getELContext(), component);
}
Iterator<UIComponent> it = component.getFacetsAndChildren();
while (it.hasNext()) {
processTree(context, it.next());
}
if (pushed) {
stackManager.pop(CompositeComponentStackManager.StackType.TreeCreation);
}
}
// hook method
owner.onComponentCreated(ctx, c, parent);
}
CompositeComponentStackManager ccStackManager =
CompositeComponentStackManager.getManager(context);
boolean compcompPushed = pushComponentToEL(ctx, c, ccStackManager);
if (ProjectStage.Development == context.getApplication().getProjectStage()) {
ComponentSupport.setTagForComponent(context, c, this.owner.getTag());
// ----------------------------------------------------- Private Methods
private boolean pushCompositeComponent(FacesContext ctx) {
CompositeComponentStackManager manager =
CompositeComponentStackManager.getManager(ctx);
UIComponent foundCc = null;
if (location != null) {
foundCc = manager.findCompositeComponentUsingLocation(ctx, location);
} else {
// We need to obtain the Location of the source expression in order
// to find the composite component that needs to be available within
// the evaluation stack.
if (source instanceof TagValueExpression) {
ValueExpression orig = ((TagValueExpression) source).getWrapped();
if (orig instanceof ContextualCompositeValueExpression) {
foundCc = manager.findCompositeComponentUsingLocation(ctx, ((ContextualCompositeValueExpression) orig).getLocation());
}
}
}
if (null == foundCc) {
foundCc = this.cc;
}
return manager.push(foundCc);
}
}
private void popCompositeComponent(FacesContext ctx) {
CompositeComponentStackManager manager =
CompositeComponentStackManager.getManager(ctx);
manager.pop();
}
Related Classes of com.sun.faces.component.CompositeComponentStackManager
Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.