Top Description Fields Constructors Methods
javax.faces.component.visit

public abstract Class VisitContext

extends Object
Class Inheritance
Known Direct Subclasses
javax.faces.component.visit.VisitContextWrapper
Imports
java.util.AbstractCollection, .Collection, .Iterator, .Set, javax.faces.FactoryFinder, javax.faces.component.UIComponent, javax.faces.context.FacesContext

A context object that is used to hold state relating to performing a component tree visit.

Component tree visits are initiated by calling UIComponent#visitTree, at which point both a VisitContext and a VisitCallback must be provided.

Since
2.0
See Also
UIComponent.visitTree(), VisitCallback

Field Summary

Modifier and TypeField and Description
public static final Collection<String>
ALL_IDS

This unmodifiable Collection is returned by getIdsToVisit() and getSubtreeIdsToVisit() in cases where all ids should be visited.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static VisitContext

Returns:

a VisitContext instance that is initialized with the specified ids and hints.
createVisitContext
(FacesContext
the FacesContext for the current request
context
,
Collection<String>
the client ids of the components to visit. If null, all components will be visited.
ids
,
Set<VisitHint>
the VisitHints to apply to the visit. If null, no hints are applied.
hints
)

Returns a VisitContext instance that is initialized with the specified ids and hintsfor use with UIComponent#visitTree.

public static VisitContext

Returns:

a VisitContext instance
createVisitContext
(FacesContext
the FacesContext for the current request
context
)

Creates a VisitContext instance for use with UIComponent.visitTree().

public abstract FacesContext

Returns:

the FacesContext.
getFacesContext
()

Returns the FacesContext for the current request.

public abstract Set<VisitHint>

Returns:

a non-empty, unmodifiable collection of VisitHints
getHints
()

Returns hints that influence the behavior of the tree visit.

public abstract Collection<String>

Returns:

the ids of the components to visit
getIdsToVisit
()

Returns the ids of the components to visit.

public abstract Collection<String>

Returns:

an unmodifiable Collection containing the client ids of any components underneath the NamingContainer that are known to be targets of the tree visit. If no such components exist, returns an empty Collection. If all components underneath the NamingContainer should be visited, returns the VisitContext.ALL_IDS collection.
getSubtreeIdsToVisit
(UIComponent
a NamingContainer component
component
)

Given a javax.faces.component.NamingContainer component, returns the client ids of any components underneath the NamingContainer that should be visited.

public abstract VisitResult

Returns:

a VisitResult value that indicates whether to continue visiting the component's subtree, skip visiting the component's subtree or abort the visit altogether.
invokeVisitCallback
(UIComponent
the component to visit
component
,
VisitCallback
the VisitCallback to call
callback
)

Called by UIComponent.visitTree() to visit a single component.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALL_IDSback to summary
public static final Collection<String> ALL_IDS

This unmodifiable Collection is returned by getIdsToVisit() and getSubtreeIdsToVisit() in cases where all ids should be visited.

To simplify logic for visitTree() implementations, this Collection always returns false for isEmpty. All other methods throw UnsupportedOperationException.

Since
2.0

Constructor Detail

VisitContextback to summary
public VisitContext()

Method Detail

createVisitContextback to summary
public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints)

Returns a VisitContext instance that is initialized with the specified ids and hintsfor use with UIComponent#visitTree.

Parameters
context:FacesContext

the FacesContext for the current request

ids:Collection<String>

the client ids of the components to visit. If null, all components will be visited.

hints:Set<VisitHint>

the VisitHints to apply to the visit. If null, no hints are applied.

Returns:VisitContext

a VisitContext instance that is initialized with the specified ids and hints.

createVisitContextback to summary
public static VisitContext createVisitContext(FacesContext context)

Creates a VisitContext instance for use with UIComponent.visitTree(). This method can be used to obtain a VisitContext instance when all components should be visited with the default visit hints.

Parameters
context:FacesContext

the FacesContext for the current request

Returns:VisitContext

a VisitContext instance

getFacesContextback to summary
public abstract FacesContext getFacesContext()

Returns the FacesContext for the current request.

Returns:FacesContext

the FacesContext.

Since
2.0
getHintsback to summary
public abstract Set<VisitHint> getHints()

Returns hints that influence the behavior of the tree visit.

Interested parties, such as UIComponent.visitTree() implementations, may check to see whether a particular hint is present by calling VisitContext.getHints().contains(), passing in one of the hints defined by VisitHint.

Returns:Set<VisitHint>

a non-empty, unmodifiable collection of VisitHints

getIdsToVisitback to summary
public abstract Collection<String> getIdsToVisit()

Returns the ids of the components to visit.

In the case of a full tree visit, this method returns the ALL_IDS collection. Otherwise, if a partial visit is beign performed, returns a modifiable collection containing the client ids of the components that should be visited.

Returns:Collection<String>

the ids of the components to visit

getSubtreeIdsToVisitback to summary
public abstract Collection<String> getSubtreeIdsToVisit(UIComponent component)

Given a javax.faces.component.NamingContainer component, returns the client ids of any components underneath the NamingContainer that should be visited.

This method is called by NamingContainer visitTree() implementations to determine whether the NamingContainer contains components to be visited. In the case where no such components exist, the NamingContainer can short-circuit the tree visit and avoid descending into child subtrees.

In addition, iterating components such as UIData may be able to use the returned ids to determine which iterated states (ie. rows) need to be visited. This allows the visit traversal to be contstrained such only those rows that contain visit targets need to be traversed.

Parameters
component:UIComponent

a NamingContainer component

Returns:Collection<String>

an unmodifiable Collection containing the client ids of any components underneath the NamingContainer that are known to be targets of the tree visit. If no such components exist, returns an empty Collection. If all components underneath the NamingContainer should be visited, returns the VisitContext.ALL_IDS collection.

Exceptions
IllegalArgumentException:
if component is not an instance of NamingContainer
invokeVisitCallbackback to summary
public abstract VisitResult invokeVisitCallback(UIComponent component, VisitCallback callback)

Called by UIComponent.visitTree() to visit a single component.

Parameters
component:UIComponent

the component to visit

callback:VisitCallback

the VisitCallback to call

Returns:VisitResult

a VisitResult value that indicates whether to continue visiting the component's subtree, skip visiting the component's subtree or abort the visit altogether.