- <h:body>
- <h:outputLabel id="label" for="@next" value="Test" />
- <h:inputText id="input">
- <f:ajax render="@this @next" />
- </h:inputText>
- <h:inputText id="input2" />
- </h:body>
javax.faces.component.search.package.html Maven / Gradle / Ivy
Show all versions of javaee-api Show documentation
Package Description for "javax.faces.component.search"
APIs for searching for components in the
component tree by using expressions.
This feature has two entry points: for the page author and for the
Java programmer. Following is a brief overview of each.
For the Page Author
The following tags support the use of search
expressions: <h:message />
, <h:messages
/>
, <h:outputLabel />
,
and <f:ajax />
. Each of those tags have one or
more attributes whose value must be a client identifier. This feature
expands the capability of those attributes to be search expressions.
A search expression is space separated list of tokens, where a token
can either be a client identifier, a search keyword, or a combination
of both. See the specification
for SearchKeywordResolver
for the list of keywords that must be supported. See the
specification
for SearchExpressionHandler
to learn how the search is performed.
Here is a brief example of the page author use case:
For the Java Programmer
Using search expressions from Java code offers more flexibility.
One must obtain a handle to
the SearchExpressionHandler
and invoke methods on it as desired.
The following example resolves to a clientId:
- SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
- SearchExpressionContext context = SearchExpressionContext.createSearchExpressionContext(facesContext, facesContext.getViewRoot());
- String clientId = handler.resolveClientId(context, ":form:container:@next");
The following example resolves to a component:
- SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
- SearchExpressionContext context = SearchExpressionContext.createSearchExpressionContext(facesContext, facesContext.getViewRoot());
- handler.resolveComponent(context, ":form:container:@next",
- new ContextCallback() {
- public void invokeContextCallback(FacesContext context,
- UIComponent target) {
- // target == the resolved component
- }
- });
The following example uses multiple expressions and therefor resolves to multiple components:
- SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
- SearchExpressionContext context = SearchExpressionContext.createSearchExpressionContext(facesContext, facesContext.getViewRoot());
- handler.resolveComponents(context, ":form:container:@next :input1 input2:@parent",
- new ContextCallback() {
- public void invokeContextCallback(FacesContext context,
- UIComponent target) {
- // target == the resolved component
- }
- });