Top Description Inners Fields Constructors Methods
com.sun.faces.facelets.impl

pack-priv final Class DefaultFaceletContext

extends FaceletContextImplBase
Class Inheritance
Imports
javax.faces.view.facelets.Facelet, .FaceletContext, com.sun.faces.facelets.FaceletContextImplBase, .TemplateClient, com.sun.faces.facelets.el.DefaultVariableMapper, javax.el.ELContext, .ELException, .ELResolver, .ExpressionFactory, .FunctionMapper, .ValueExpression, .VariableMapper, javax.faces.FacesException, javax.faces.component.UIComponent, javax.faces.context.FacesContext, java.io.IOException, java.net.URL, java.util.ArrayList, .HashMap, .HashSet, .Iterator, .List, .Map, .Set

Default FaceletContext implementation. A single FaceletContext is used for all Facelets involved in an invocation of Facelet#apply(FacesContext, UIComponent). This means that included Facelets are treated the same as the JSP include directive.
Author
Jacob Hookom
Version
$Id: DefaultFaceletContext.java,v 1.4.4.3 2006/03/25 01:01:53 jhook Exp $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final List<DefaultFaceletContext.TemplateManager>
private final ELContext
private final DefaultFacelet
private final List<Facelet>
private final FacesContext
private FunctionMapper
private final Map<String, Integer>
private String
private final Map<Integer, Integer>
private final StringBuilder
private VariableMapper

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public void
public String
generateUniqueId(String
the string from which to generate the ID.
base
)

Implements abstract javax.faces.view.facelets.FaceletContext.generateUniqueId.

Generate a unique ID for the passed String

public Object
getAttribute(String
the name of the attribute to return.
name
)

Implements abstract javax.faces.view.facelets.FaceletContext.getAttribute.

Return an attribute set by a previous call to setAttribute.

public Object
getContext(Class<T>
The unique identifier that was used to associate the context object with this ELContext.
key
)

Overrides javax.el.ELContext.getContext.

Returns the context object associated with the given key.
public ELResolver
getELResolver()

Implements abstract javax.el.ELContext.getELResolver.

Retrieves the ELResolver associated with this context.
public ExpressionFactory
getExpressionFactory()

Implements abstract javax.faces.view.facelets.FaceletContext.getExpressionFactory.

The ExpressionFactory to use within the Facelet this context is executing upon.

public FacesContext
getFacesContext()

Implements abstract javax.faces.view.facelets.FaceletContext.getFacesContext.

The current FacesContext bound to this "request".

public FunctionMapper
getFunctionMapper()

Implements abstract javax.el.ELContext.getFunctionMapper.

Retrieves the FunctionMapper associated with this ELContext.
public VariableMapper
getVariableMapper()

Implements abstract javax.el.ELContext.getVariableMapper.

Retrieves the VariableMapper associated with this ELContext.
public boolean
includeDefinition(UIComponent
the UIComponent to apply to
parent
,
String
name or null of the definition you want to apply
name
)

Implements abstract com.sun.faces.facelets.FaceletContextImplBase.includeDefinition.

This method will walk through the TemplateClient stack to resolve and apply the definition for the passed name.
public void
includeFacelet(UIComponent
the UIComponent that will be the parent of any components in the included facelet.
parent
,
String
the path of the resource containing the facelet markup, relative to the current markup
relativePath
)

Implements abstract javax.faces.view.facelets.FaceletContext.includeFacelet.

Include another Facelet defined at some path, relative to the executing context, not the current Facelet (same as include directive in JSP)

public void
includeFacelet(UIComponent
the UIComponent that will be the parent of any components in the included facelet.
parent
,
URL
the absolute path to the resource containing the facelet markup
absolutePath
)

Implements abstract javax.faces.view.facelets.FaceletContext.includeFacelet.

Include another Facelet defined at some path, absolute to this ClassLoader/OS

public boolean
isPropertyResolved()

Overrides javax.el.ELContext.isPropertyResolved.

Returns whether an ELResolver has successfully resolved a given (base, property) pair.
public void
popClient(TemplateClient client)

Implements abstract com.sun.faces.facelets.FaceletContextImplBase.popClient.

Pop the last added TemplateClient
public void
pushClient(final TemplateClient client)

Implements abstract com.sun.faces.facelets.FaceletContextImplBase.pushClient.

Push the passed TemplateClient onto the stack for Definition Resolution
public void
putContext(Class<T>
The key used by an @{link ELResolver} to identify this context object.
key
,
Object
The context object to add to the collection.
contextObject
)

Overrides javax.el.ELContext.putContext.

Associates a context object with this ELContext.
public void
setAttribute(String
the name of the attribute
name
,
Object
the value of the attribute
value
)

Implements abstract javax.faces.view.facelets.FaceletContext.setAttribute.

Support method which is backed by the current VariableMapper.

public void
setFunctionMapper(FunctionMapper
the new FunctionMapper
fnMapper
)

Implements abstract javax.faces.view.facelets.FaceletContext.setFunctionMapper.

Set the FunctionMapper to use in EL evaluation/creation.

public void
setPropertyResolved(boolean
true if the property has been resolved, or false if not.
resolved
)

Overrides javax.el.ELContext.setPropertyResolved.

Called to indicate that a ELResolver has successfully resolved a given (base, property) pair.
public void
setVariableMapper(VariableMapper
the new VariableMapper
varMapper
)

Implements abstract javax.faces.view.facelets.FaceletContext.setVariableMapper.

Set the VariableMapper to use in EL evaluation/creation.

Field Detail

clientsback to summary
private final List<DefaultFaceletContext.TemplateManager> clients
ctxback to summary
private final ELContext ctx
faceletback to summary
private final DefaultFacelet facelet
faceletHierarchyback to summary
private final List<Facelet> faceletHierarchy
facesback to summary
private final FacesContext faces
fnMapperback to summary
private FunctionMapper fnMapper
idsback to summary
private final Map<String, Integer> ids
prefixback to summary
private String prefix
prefixesback to summary
private final Map<Integer, Integer> prefixes
uniqueIdBuilderback to summary
private final StringBuilder uniqueIdBuilder
varMapperback to summary
private VariableMapper varMapper

Constructor Detail

DefaultFaceletContextback to summary
public DefaultFaceletContext(DefaultFaceletContext ctx, DefaultFacelet facelet)
DefaultFaceletContextback to summary
public DefaultFaceletContext(FacesContext faces, DefaultFacelet facelet)

Method Detail

extendClientback to summary
public void extendClient(final TemplateClient client)

Implements abstract com.sun.faces.facelets.FaceletContextImplBase.extendClient.

Annotations
@Override
generateUniqueIdback to summary
public String generateUniqueId(String base)

Implements abstract javax.faces.view.facelets.FaceletContext.generateUniqueId.

Doc from javax.faces.view.facelets.FaceletContext.generateUniqueId.

Generate a unique ID for the passed String

Parameters
base:String

the string from which to generate the ID.

Returns:String

the generated id

Annotations
@Override
getAttributeback to summary
public Object getAttribute(String name)

Implements abstract javax.faces.view.facelets.FaceletContext.getAttribute.

Doc from javax.faces.view.facelets.FaceletContext.getAttribute.

Return an attribute set by a previous call to setAttribute. Support method which is backed by the current VariableMapper

Parameters
name:String

the name of the attribute to return.

Returns:Object

the value of the named attribute

Annotations
@Override
getContextback to summary
public Object getContext(Class<T> key)

Overrides javax.el.ELContext.getContext.

Doc from javax.el.ELContext.getContext.

Returns the context object associated with the given key.

The ELContext maintains a collection of context objects relevant to the evaluation of an expression. These context objects are used by ELResolvers. This method is used to retrieve the context with the given key from the collection.

By convention, the object returned will be of the type specified by the key. However, this is not required and the key is used strictly as a unique identifier.

Parameters
key:Class<T>

The unique identifier that was used to associate the context object with this ELContext.

Returns:Object

The context object associated with the given key, or null if no such context was found.

Annotations
@Override
getELResolverback to summary
public ELResolver getELResolver()

Implements abstract javax.el.ELContext.getELResolver.

Doc from javax.el.ELContext.getELResolver.

Retrieves the ELResolver associated with this context.

The ELContext maintains a reference to the ELResolver that will be consulted to resolve variables and properties during an expression evaluation. This method retrieves the reference to the resolver.

Once an ELContext is constructed, the reference to the ELResolver associated with the context cannot be changed.

Returns:ELResolver

The resolver to be consulted for variable and property resolution during expression evaluation.

Annotations
@Override
getExpressionFactoryback to summary
public ExpressionFactory getExpressionFactory()

Implements abstract javax.faces.view.facelets.FaceletContext.getExpressionFactory.

Doc from javax.faces.view.facelets.FaceletContext.getExpressionFactory.

The ExpressionFactory to use within the Facelet this context is executing upon. Must not be null.

Returns:ExpressionFactory

the ExpressionFactory for this Facelet.

Annotations
@Override
getFacesContextback to summary
public FacesContext getFacesContext()

Implements abstract javax.faces.view.facelets.FaceletContext.getFacesContext.

Doc from javax.faces.view.facelets.FaceletContext.getFacesContext.

The current FacesContext bound to this "request". Must not be null.

Returns:FacesContext

The current FacesContext bound to this "request".

Annotations
@Override
getFunctionMapperback to summary
public FunctionMapper getFunctionMapper()

Implements abstract javax.el.ELContext.getFunctionMapper.

Doc from javax.el.ELContext.getFunctionMapper.

Retrieves the FunctionMapper associated with this ELContext.

Returns:FunctionMapper

The function mapper to be consulted for the resolution of EL functions.

Annotations
@Override
getVariableMapperback to summary
public VariableMapper getVariableMapper()

Implements abstract javax.el.ELContext.getVariableMapper.

Doc from javax.el.ELContext.getVariableMapper.

Retrieves the VariableMapper associated with this ELContext.

Returns:VariableMapper

The variable mapper to be consulted for the resolution of EL variables.

Annotations
@Override
includeDefinitionback to summary
public boolean includeDefinition(UIComponent parent, String name) throws IOException

Implements abstract com.sun.faces.facelets.FaceletContextImplBase.includeDefinition.

Doc from com.sun.faces.facelets.FaceletContextImplBase.includeDefinition.

This method will walk through the TemplateClient stack to resolve and apply the definition for the passed name. If it's been resolved and applied, this method will return true.

Parameters
parent:UIComponent

the UIComponent to apply to

name:String

name or null of the definition you want to apply

Returns:boolean

true if successfully applied, otherwise false

Annotations
@Override
includeFaceletback to summary
public void includeFacelet(UIComponent parent, String relativePath) throws IOException, FacesException, ELException

Implements abstract javax.faces.view.facelets.FaceletContext.includeFacelet.

Doc from javax.faces.view.facelets.FaceletContext.includeFacelet.

Include another Facelet defined at some path, relative to the executing context, not the current Facelet (same as include directive in JSP)

Parameters
parent:UIComponent

the UIComponent that will be the parent of any components in the included facelet.

relativePath:String

the path of the resource containing the facelet markup, relative to the current markup

Annotations
@Override
Exceptions
IOException:
if unable to load relativePath
FacesException:
if unable to create child UIComponent instances
ELException:
if any of the expressions in the markup loaded from relativePath fail
includeFaceletback to summary
public void includeFacelet(UIComponent parent, URL absolutePath) throws IOException, FacesException, ELException

Implements abstract javax.faces.view.facelets.FaceletContext.includeFacelet.

Doc from javax.faces.view.facelets.FaceletContext.includeFacelet.

Include another Facelet defined at some path, absolute to this ClassLoader/OS

Parameters
parent:UIComponent

the UIComponent that will be the parent of any components in the included facelet.

absolutePath:URL

the absolute path to the resource containing the facelet markup

Annotations
@Override
Exceptions
IOException:
if unable to load relativePath
FacesException:
if unable to create child UIComponent instances
ELException:
if any of the expressions in the markup loaded from relativePath fail
isPropertyResolvedback to summary
public boolean isPropertyResolved()

Overrides javax.el.ELContext.isPropertyResolved.

Doc from javax.el.ELContext.isPropertyResolved.

Returns whether an ELResolver has successfully resolved a given (base, property) pair.

The CompositeELResolver checks this property to determine whether it should consider or skip other component resolvers.

Returns:boolean

true if the property has been resolved, or false if not.

Annotations
@Override
popClientback to summary
public void popClient(TemplateClient client)

Implements abstract com.sun.faces.facelets.FaceletContextImplBase.popClient.

Doc from com.sun.faces.facelets.FaceletContextImplBase.popClient.

Pop the last added TemplateClient

Annotations
@Override
pushClientback to summary
public void pushClient(final TemplateClient client)

Implements abstract com.sun.faces.facelets.FaceletContextImplBase.pushClient.

Doc from com.sun.faces.facelets.FaceletContextImplBase.pushClient.

Push the passed TemplateClient onto the stack for Definition Resolution

Annotations
@Override
putContextback to summary
public void putContext(Class<T> key, Object contextObject)

Overrides javax.el.ELContext.putContext.

Doc from javax.el.ELContext.putContext.

Associates a context object with this ELContext.

The ELContext maintains a collection of context objects relevant to the evaluation of an expression. These context objects are used by ELResolvers. This method is used to add a context object to that collection.

By convention, the contextObject will be of the type specified by the key. However, this is not required and the key is used strictly as a unique identifier.

Parameters
key:Class<T>

The key used by an @{link ELResolver} to identify this context object.

contextObject:Object

The context object to add to the collection.

Annotations
@Override
setAttributeback to summary
public void setAttribute(String name, Object value)

Implements abstract javax.faces.view.facelets.FaceletContext.setAttribute.

Doc from javax.faces.view.facelets.FaceletContext.setAttribute.

Support method which is backed by the current VariableMapper.

Parameters
name:String

the name of the attribute

value:Object

the value of the attribute

Annotations
@Override
setFunctionMapperback to summary
public void setFunctionMapper(FunctionMapper fnMapper)

Implements abstract javax.faces.view.facelets.FaceletContext.setFunctionMapper.

Doc from javax.faces.view.facelets.FaceletContext.setFunctionMapper.

Set the FunctionMapper to use in EL evaluation/creation.

Parameters
fnMapper:FunctionMapper

the new FunctionMapper

Annotations
@Override
setPropertyResolvedback to summary
public void setPropertyResolved(boolean resolved)

Overrides javax.el.ELContext.setPropertyResolved.

Doc from javax.el.ELContext.setPropertyResolved.

Called to indicate that a ELResolver has successfully resolved a given (base, property) pair. Use setPropertyResolved(Object, Object) if resolved is true and to notify EvaluationListeners.

The CompositeELResolver checks this property to determine whether it should consider or skip other component resolvers.

Parameters
resolved:boolean

true if the property has been resolved, or false if not.

Annotations
@Override
setVariableMapperback to summary
public void setVariableMapper(VariableMapper varMapper)

Implements abstract javax.faces.view.facelets.FaceletContext.setVariableMapper.

Doc from javax.faces.view.facelets.FaceletContext.setVariableMapper.

Set the VariableMapper to use in EL evaluation/creation.

Parameters
varMapper:VariableMapper

the new VariableMapper

Annotations
@Override
com.sun.faces.facelets.impl back to summary

private final Class DefaultFaceletContext.TemplateManager

extends Object
implements TemplateClient
Class Inheritance
  • java.lang.Object
  • com.sun.faces.facelets.impl.DefaultFaceletContext.TemplateManager
All Implemented Interfaces
com.sun.faces.facelets.TemplateClient

Field Summary

Modifier and TypeField and Description
private final Set<String>
private final DefaultFacelet
private final boolean
private final TemplateClient

Constructor Summary

AccessConstructor and Description
public
TemplateManager(DefaultFacelet owner, TemplateClient target, boolean root)

Method Summary

Modifier and TypeMethod and Description
public boolean
apply(FaceletContext
the FaceletContext of your instance, not the templates'
ctx
,
UIComponent
current UIComponent instance to be applied
parent
,
String
the String name or null if the whole body should be included
name
)

Implements com.sun.faces.facelets.TemplateClient.apply.

This contract is much like the normal FaceletHandler.apply method, but it takes in an optional String name which tells this instance what fragment/definition it's looking for.
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public boolean
Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

namesback to summary
private final Set<String> names
ownerback to summary
private final DefaultFacelet owner
rootback to summary
private final boolean root
targetback to summary
private final TemplateClient target

Constructor Detail

TemplateManagerback to summary
public TemplateManager(DefaultFacelet owner, TemplateClient target, boolean root)

Method Detail

applyback to summary
public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException

Implements com.sun.faces.facelets.TemplateClient.apply.

Doc from com.sun.faces.facelets.TemplateClient.apply.

This contract is much like the normal FaceletHandler.apply method, but it takes in an optional String name which tells this instance what fragment/definition it's looking for. If you are a match, apply your logic to the passed UIComponent and return true, otherwise do nothing and return false.

Parameters
ctx:FaceletContext

the FaceletContext of your instance, not the templates'

parent:UIComponent

current UIComponent instance to be applied

name:String

the String name or null if the whole body should be included

Returns:boolean

true if this client matched/applied the definition for the passed name

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
isRootback to summary
public boolean isRoot()