use of com.sun.faces.component.search.CompositeSearchKeywordResolver in project mojarra by eclipse-ee4j.
the class SearchExpressionHandlerTest method test_chainOfResponsability.
public void test_chainOfResponsability() {
CompositeSearchKeywordResolver s = (CompositeSearchKeywordResolver) application.getSearchKeywordResolver();
// drop in new @form resolver
s.add(new CustomSearchKeywordResolverImplForm());
UIComponent root = new UIPanel();
UIForm form = new UIForm();
root.getChildren().add(form);
UINamingContainer outerContainer = new UINamingContainer();
form.getChildren().add(outerContainer);
UINamingContainer innerContainer = new UINamingContainer();
outerContainer.getChildren().add(innerContainer);
UIComponent component = new UIOutput();
innerContainer.getChildren().add(component);
UIComponent source = new UICommand();
innerContainer.getChildren().add(source);
assertSame("Failed", source, resolveComponent(source, "@form"));
assertNotSame("Failed", form, resolveComponent(source, "@form"));
}
use of com.sun.faces.component.search.CompositeSearchKeywordResolver in project mojarra by eclipse-ee4j.
the class SearchExpressionHandlerTest method test_PFS.
/**
* The SearchExpression API was inspired by PrimeFaces. This test only tests, if PFS (PrimeFaces Selectors -> jQuery
* like selectors; like @(#myId > .myStyle)) can be correctly handled by the API+IMPL as a passthrough expression.
*/
public void test_PFS() {
CompositeSearchKeywordResolver s = (CompositeSearchKeywordResolver) application.getSearchKeywordResolver();
s.add(new SearchKeywordResolver() {
@Override
public void resolve(SearchKeywordContext searchKeywordContext, UIComponent previous, String keyword) {
}
@Override
public boolean isResolverForKeyword(SearchExpressionContext searchExpressionContext, String keyword) {
return keyword.startsWith("(") && keyword.endsWith(")");
}
@Override
public boolean isPassthrough(SearchExpressionContext searchExpressionContext, String keyword) {
return true;
}
@Override
public boolean isLeaf(SearchExpressionContext searchExpressionContext, String keyword) {
return true;
}
});
UIComponent root = new UIPanel();
FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root);
assertEquals("@(.myPanel #id)", resolveClientId(root, " @(.myPanel #id)"));
SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
SearchExpressionContext searchExpressionContext = SearchExpressionContext.createSearchExpressionContext(facesContext, null);
Assert.assertTrue(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id)"));
Assert.assertFalse(handler.isValidExpression(searchExpressionContext, "@(.myPanel #id):test"));
}
use of com.sun.faces.component.search.CompositeSearchKeywordResolver in project mojarra by eclipse-ee4j.
the class SearchExpressionHandlerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null);
root.setViewId("/viewId");
facesContext.setViewRoot(root);
RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
RenderKit renderKit = new MockRenderKit();
try {
renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
} catch (IllegalArgumentException e) {
}
FactoryFinder.setFactory(FactoryFinder.SEARCH_EXPRESSION_CONTEXT_FACTORY, SearchExpressionContextFactoryImpl.class.getName());
FactoryFinder.setFactory(FactoryFinder.VISIT_CONTEXT_FACTORY, VisitContextFactoryImpl.class.getName());
SearchExpressionHandlerImpl expressionHandlerImpl = new SearchExpressionHandlerImpl();
application.setSearchExpressionHandler(expressionHandlerImpl);
CompositeSearchKeywordResolver searchKeywordResolvers = new CompositeSearchKeywordResolver();
searchKeywordResolvers.add(new SearchKeywordResolverImplThis());
searchKeywordResolvers.add(new SearchKeywordResolverImplParent());
searchKeywordResolvers.add(new SearchKeywordResolverImplForm());
searchKeywordResolvers.add(new SearchKeywordResolverImplComposite());
searchKeywordResolvers.add(new SearchKeywordResolverImplNext());
searchKeywordResolvers.add(new SearchKeywordResolverImplPrevious());
searchKeywordResolvers.add(new SearchKeywordResolverImplNone());
searchKeywordResolvers.add(new SearchKeywordResolverImplNamingContainer());
searchKeywordResolvers.add(new SearchKeywordResolverImplRoot());
searchKeywordResolvers.add(new SearchKeywordResolverImplId());
searchKeywordResolvers.add(new SearchKeywordResolverImplChild());
searchKeywordResolvers.add(new SearchKeywordResolverImplAll());
application.setSearchKeywordResolver(searchKeywordResolvers);
}
Aggregations