Search in sources :

Example 1 with CompositeSearchKeywordResolver

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"));
}
Also used : CompositeSearchKeywordResolver(com.sun.faces.component.search.CompositeSearchKeywordResolver)

Example 2 with CompositeSearchKeywordResolver

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"));
}
Also used : SearchExpressionHandler(jakarta.faces.component.search.SearchExpressionHandler) SearchExpressionContext(jakarta.faces.component.search.SearchExpressionContext) SearchKeywordResolver(jakarta.faces.component.search.SearchKeywordResolver) CompositeSearchKeywordResolver(com.sun.faces.component.search.CompositeSearchKeywordResolver) CompositeSearchKeywordResolver(com.sun.faces.component.search.CompositeSearchKeywordResolver) SearchKeywordContext(jakarta.faces.component.search.SearchKeywordContext)

Example 3 with CompositeSearchKeywordResolver

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);
}
Also used : SearchKeywordResolverImplForm(com.sun.faces.component.search.SearchKeywordResolverImplForm) SearchExpressionContextFactoryImpl(com.sun.faces.component.search.SearchExpressionContextFactoryImpl) SearchKeywordResolverImplAll(com.sun.faces.component.search.SearchKeywordResolverImplAll) SearchKeywordResolverImplComposite(com.sun.faces.component.search.SearchKeywordResolverImplComposite) SearchKeywordResolverImplRoot(com.sun.faces.component.search.SearchKeywordResolverImplRoot) SearchKeywordResolverImplPrevious(com.sun.faces.component.search.SearchKeywordResolverImplPrevious) SearchKeywordResolverImplNamingContainer(com.sun.faces.component.search.SearchKeywordResolverImplNamingContainer) CompositeSearchKeywordResolver(com.sun.faces.component.search.CompositeSearchKeywordResolver) VisitContextFactoryImpl(com.sun.faces.component.visit.VisitContextFactoryImpl) SearchKeywordResolverImplParent(com.sun.faces.component.search.SearchKeywordResolverImplParent) SearchKeywordResolverImplNone(com.sun.faces.component.search.SearchKeywordResolverImplNone) SearchExpressionHandlerImpl(com.sun.faces.component.search.SearchExpressionHandlerImpl) SearchKeywordResolverImplThis(com.sun.faces.component.search.SearchKeywordResolverImplThis) SearchKeywordResolverImplId(com.sun.faces.component.search.SearchKeywordResolverImplId) SearchKeywordResolverImplNext(com.sun.faces.component.search.SearchKeywordResolverImplNext) RenderKit(jakarta.faces.render.RenderKit) MockRenderKit(com.sun.faces.mock.MockRenderKit) MockRenderKit(com.sun.faces.mock.MockRenderKit) SearchKeywordResolverImplChild(com.sun.faces.component.search.SearchKeywordResolverImplChild) RenderKitFactory(jakarta.faces.render.RenderKitFactory)

Aggregations

CompositeSearchKeywordResolver (com.sun.faces.component.search.CompositeSearchKeywordResolver)3 SearchExpressionContextFactoryImpl (com.sun.faces.component.search.SearchExpressionContextFactoryImpl)1 SearchExpressionHandlerImpl (com.sun.faces.component.search.SearchExpressionHandlerImpl)1 SearchKeywordResolverImplAll (com.sun.faces.component.search.SearchKeywordResolverImplAll)1 SearchKeywordResolverImplChild (com.sun.faces.component.search.SearchKeywordResolverImplChild)1 SearchKeywordResolverImplComposite (com.sun.faces.component.search.SearchKeywordResolverImplComposite)1 SearchKeywordResolverImplForm (com.sun.faces.component.search.SearchKeywordResolverImplForm)1 SearchKeywordResolverImplId (com.sun.faces.component.search.SearchKeywordResolverImplId)1 SearchKeywordResolverImplNamingContainer (com.sun.faces.component.search.SearchKeywordResolverImplNamingContainer)1 SearchKeywordResolverImplNext (com.sun.faces.component.search.SearchKeywordResolverImplNext)1 SearchKeywordResolverImplNone (com.sun.faces.component.search.SearchKeywordResolverImplNone)1 SearchKeywordResolverImplParent (com.sun.faces.component.search.SearchKeywordResolverImplParent)1 SearchKeywordResolverImplPrevious (com.sun.faces.component.search.SearchKeywordResolverImplPrevious)1 SearchKeywordResolverImplRoot (com.sun.faces.component.search.SearchKeywordResolverImplRoot)1 SearchKeywordResolverImplThis (com.sun.faces.component.search.SearchKeywordResolverImplThis)1 VisitContextFactoryImpl (com.sun.faces.component.visit.VisitContextFactoryImpl)1 MockRenderKit (com.sun.faces.mock.MockRenderKit)1 SearchExpressionContext (jakarta.faces.component.search.SearchExpressionContext)1 SearchExpressionHandler (jakarta.faces.component.search.SearchExpressionHandler)1 SearchKeywordContext (jakarta.faces.component.search.SearchKeywordContext)1