public abstract class SearchExpressionHandler
extends java.lang.Object
A search expression consists of either an identifier
(which is matched exactly against the id
property of
a UIComponent
, or a keyword (like @this
or @form
),
or a series of such identifiers and keywords linked by
the UINamingContainer.getSeparatorChar(javax.faces.context.FacesContext)
character value.
See SearchKeywordResolver
for the list of supported keywords.
The search algorithm must operate as follows, though alternate
alogrithms may be used as long as the end result is the same:
UIComponent
that will be the base for searching:
UIViewRoot
.
The leading separator character will be stripped off,
and the remainder of the search expression will be treated as
a "relative" search expression as described below.
SearchExpressionContext.getSource()
will be used.
UINamingContainer.getSeparatorChar(javax.faces.context.FacesContext)
into "commands".
The commands will be resolved one by one.
For the first command, the source component, like mentioned above, will be used to start the lookup.
For all further commands, the previous resolved component, from the previous command, will be used the start the lookup.
KEYWORD_PREFIX
, then it is considered as a keyword and the
SearchKeywordResolver
s will be used the resolve the keyword.
KEYWORD_PREFIX
, then the component will be resolved
based on the component ID.
Modifier and Type | Field and Description |
---|---|
protected static char[] |
EXPRESSION_SEPARATOR_CHARS
The default characters used to separate expressions in a series of expressions. |
static java.lang.String |
KEYWORD_PREFIX
The prefix to identify a keyword. |
Constructor and Description |
---|
SearchExpressionHandler() |
Modifier and Type | Method and Description |
---|---|
char[] |
getExpressionSeperatorChars(FacesContext context)
Return the characters used to separate expressions in a series of expressions. |
void |
invokeOnComponent(SearchExpressionContext searchExpressionContext,
java.lang.String expression,
ContextCallback callback)
Resolves multiple |
abstract void |
invokeOnComponent(SearchExpressionContext searchExpressionContext,
UIComponent previous,
java.lang.String expression,
ContextCallback callback)
Resolves multiple |
abstract boolean |
isPassthroughExpression(SearchExpressionContext searchExpressionContext,
java.lang.String expression)
Checks if the given expression is a "passtrough expression". |
abstract boolean |
isValidExpression(SearchExpressionContext searchExpressionContext,
java.lang.String expression)
Checks if the given expression is a valid expression. |
abstract java.lang.String |
resolveClientId(SearchExpressionContext searchExpressionContext,
java.lang.String expression)
Resolves to a single clientId or passthrough expression for the given expression. |
abstract java.util.List<java.lang.String> |
resolveClientIds(SearchExpressionContext searchExpressionContext,
java.lang.String expressions)
Resolves to a |
abstract void |
resolveComponent(SearchExpressionContext searchExpressionContext,
java.lang.String expression,
ContextCallback callback)
Resolves a single |
abstract void |
resolveComponents(SearchExpressionContext searchExpressionContext,
java.lang.String expressions,
ContextCallback callback)
Resolves multiple |
abstract java.lang.String[] |
splitExpressions(FacesContext context,
java.lang.String expressions)
Splits an string, based on
|
public static final java.lang.String KEYWORD_PREFIX
The prefix to identify a keyword.
protected static final char[] EXPRESSION_SEPARATOR_CHARS
The default characters used to separate expressions in a series of expressions. Expressions are per default separated by space and comma.
public abstract java.lang.String resolveClientId(SearchExpressionContext searchExpressionContext, java.lang.String expression)
Resolves to a single clientId or passthrough expression for the given expression.
searchExpressionContext
- the SearchExpressionContext
expression
- the search expressionSearchExpressionHint.IGNORE_NO_RESULT
was passed, null
will be returned.ComponentNotFoundException
- if the expression can not be resolved
and if SearchExpressionHint.IGNORE_NO_RESULT
was not passed.FacesException
- if the expression is not valid.public abstract java.util.List<java.lang.String> resolveClientIds(SearchExpressionContext searchExpressionContext, java.lang.String expressions)
Resolves to a List
with clientIds or passthrough expressions for the given expressions.
The expressions will be splitted by splitExpressions(javax.faces.context.FacesContext, java.lang.String)
and resolved one by one.
searchExpressionContext
- the SearchExpressionContext
expressions
- the search expressionsComponentNotFoundException
- if one of the expression can not be resolved
and if SearchExpressionHint.IGNORE_NO_RESULT
was not passed.FacesException
- if the expression is not valid.public abstract void resolveComponent(SearchExpressionContext searchExpressionContext, java.lang.String expression, ContextCallback callback)
Resolves a single UIComponent
s for the given
expression. If the component is resolved, the ContextCallback
will be invoked.
searchExpressionContext
- the SearchExpressionContext
expression
- the search expressioncallback
- the callback for the resolved componentComponentNotFoundException
- if the expression can not be resolved
and if SearchExpressionHint.IGNORE_NO_RESULT
was not passed.FacesException
- if the expression is not valid.public abstract void resolveComponents(SearchExpressionContext searchExpressionContext, java.lang.String expressions, ContextCallback callback)
Resolves multiple UIComponent
s for the given expression(s).
The expressions will be splitted by splitExpressions(javax.faces.context.FacesContext, java.lang.String)
and resolved one by one.
For each resolved component, the ContextCallback
will be invoked.
searchExpressionContext
- the SearchExpressionContext
expressions
- the search expression(s)callback
- the callback for each resolved componentComponentNotFoundException
- if any of the expressions can not be resolved
and if SearchExpressionHint.IGNORE_NO_RESULT
was not passed.FacesException
- if the expression is not valid.public void invokeOnComponent(SearchExpressionContext searchExpressionContext, java.lang.String expression, ContextCallback callback)
Resolves multiple UIComponent
s for the given
expression. For each resolved component, the ContextCallback
will be invoked.
This method is the most essential method in the API.
It implements the algorithm which handles the recursion of the keywords and id's.
searchExpressionContext
- the SearchExpressionContext
expression
- the search expressioncallback
- the callback for the resolved componentFacesException
- if the expression is not valid.public abstract void invokeOnComponent(SearchExpressionContext searchExpressionContext, UIComponent previous, java.lang.String expression, ContextCallback callback)
Resolves multiple UIComponent
s for the given
expression. For each resolved component, the ContextCallback
will be invoked.
This method is the most essential method in the API.
It implements the algorithm which handles the recursion of the keywords and id's.
searchExpressionContext
- the SearchExpressionContext
previous
- The previous resolved component, that will be the base for searchingexpression
- the search expressioncallback
- the callback for the resolved componentFacesException
- if the expression is not valid.public abstract java.lang.String[] splitExpressions(FacesContext context, java.lang.String expressions)
Splits an string, based on
getExpressionSeperatorChars(javax.faces.context.FacesContext)
with possible multiple expressions into an array.
context
- the FacesContext
for the current requestexpressions
- The expressions as stringpublic abstract boolean isPassthroughExpression(SearchExpressionContext searchExpressionContext, java.lang.String expression)
Checks if the given expression is a "passtrough expression".
A passthrough expression must only be a keyword.
This keyword will not be resolved by the SearchKeywordResolver
and will be returned untouched.
The client is responsible to resolve it later.
searchExpressionContext
- the SearchExpressionContext
expression
- the expressionpublic abstract boolean isValidExpression(SearchExpressionContext searchExpressionContext, java.lang.String expression)
Checks if the given expression is a valid expression.
SearchKeywordResolver
matches the requested keywordsearchExpressionContext
- the SearchExpressionContext
expression
- the expressionpublic char[] getExpressionSeperatorChars(FacesContext context)
Return the characters used to separate expressions
in a series of expressions.
The default implementation returns EXPRESSION_SEPARATOR_CHARS
.
context
- the FacesContext
for the current request