Search in sources :

Example 26 with UINamingContainer

use of javax.faces.component.UINamingContainer in project primefaces by primefaces.

the class SearchExpressionFacadeTest method resolveClientIds_RelativeAndPFSAndWidgetVarAndFormParent.

@Test
public void resolveClientIds_RelativeAndPFSAndWidgetVarAndFormParent() {
    UIComponent root = new UIPanel();
    root.setId("root");
    UIForm form = new UIForm();
    form.setId("form");
    root.getChildren().add(form);
    UINamingContainer outerContainer = new UINamingContainer();
    outerContainer.setId("outerContainer");
    form.getChildren().add(outerContainer);
    UINamingContainer innerContainer = new UINamingContainer();
    innerContainer.setId("innerContainer");
    outerContainer.getChildren().add(innerContainer);
    UIComponent component = new UIOutput();
    component.setId("other");
    innerContainer.getChildren().add(component);
    UIComponent source = new UICommand();
    source.setId("source");
    innerContainer.getChildren().add(source);
    assertEquals("form:outerContainer:innerContainer:other @(.myClass, .myClass2) @widgetVar(test) root @(.myClass :not:(select))", resolveClientIds(source, " other,@(.myClass, .myClass2) @widgetVar(test),@form:@parent @(.myClass :not:(select))"));
}
Also used : UIOutput(javax.faces.component.UIOutput) UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) UIForm(javax.faces.component.UIForm) UICommand(javax.faces.component.UICommand) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Example 27 with UINamingContainer

use of javax.faces.component.UINamingContainer in project primefaces by primefaces.

the class SearchExpressionFacadeTest method resolveComponents_SimpleMultiSearchExpressionResolver_ParentParent.

@Test
public void resolveComponents_SimpleMultiSearchExpressionResolver_ParentParent() {
    UIComponent root = new UIPanel();
    FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root);
    UIForm form = new UIForm();
    form.setId("form");
    form.setPrependId(false);
    root.getChildren().add(form);
    UINamingContainer outerContainer = new UINamingContainer();
    outerContainer.setId("outerContainer");
    form.getChildren().add(outerContainer);
    UINamingContainer innerContainer = new UINamingContainer();
    innerContainer.setId("innerContainer");
    outerContainer.getChildren().add(innerContainer);
    ArrayList<UIComponent> components = new ArrayList<>();
    components.add(outerContainer);
    components.add(innerContainer);
    SearchExpressionResolverFactory.registerResolver("@test", new TestMultiSearchExpressionResolver(components));
    List<UIComponent> result = resolveComponents(root, " @test:@parent:@parent ");
    assertTrue(result.size() == 2);
    assertTrue(result.contains(root));
    assertTrue(result.contains(form));
    SearchExpressionResolverFactory.removeResolver("@test");
}
Also used : UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) ArrayList(java.util.ArrayList) UIForm(javax.faces.component.UIForm) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Example 28 with UINamingContainer

use of javax.faces.component.UINamingContainer in project primefaces by primefaces.

the class SearchExpressionFacadeTest method resolveClientId_None.

@Test
public void resolveClientId_None() {
    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);
    assertEquals("@none", resolveClientId(source, " @none", EnumSet.of(SearchExpressionHint.RESOLVE_CLIENT_SIDE)));
}
Also used : UIOutput(javax.faces.component.UIOutput) UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) UIForm(javax.faces.component.UIForm) UICommand(javax.faces.component.UICommand) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Example 29 with UINamingContainer

use of javax.faces.component.UINamingContainer in project primefaces by primefaces.

the class SearchExpressionFacadeTest method resolveClientIds_RelativeAndThisParent.

@Test
public void resolveClientIds_RelativeAndThisParent() {
    UIComponent root = new UIPanel();
    UIForm form = new UIForm();
    form.setId("form");
    root.getChildren().add(form);
    UINamingContainer outerContainer = new UINamingContainer();
    outerContainer.setId("outerContainer");
    form.getChildren().add(outerContainer);
    UINamingContainer innerContainer = new UINamingContainer();
    innerContainer.setId("innerContainer");
    outerContainer.getChildren().add(innerContainer);
    UIComponent component = new UIOutput();
    component.setId("other");
    innerContainer.getChildren().add(component);
    UIComponent source = new UICommand();
    source.setId("source");
    innerContainer.getChildren().add(source);
    assertEquals("form:outerContainer:innerContainer:other form:outerContainer:innerContainer", resolveClientIds(source, " other @this:@parent"));
}
Also used : UIOutput(javax.faces.component.UIOutput) UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) UIForm(javax.faces.component.UIForm) UICommand(javax.faces.component.UICommand) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Example 30 with UINamingContainer

use of javax.faces.component.UINamingContainer in project primefaces by primefaces.

the class SearchExpressionFacadeTest method resolveComponents_SimpleMultiSearchExpressionResolver.

@Test
public void resolveComponents_SimpleMultiSearchExpressionResolver() {
    UIComponent root = new UIPanel();
    FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root);
    UIForm form = new UIForm();
    form.setId("form");
    form.setPrependId(false);
    root.getChildren().add(form);
    UINamingContainer outerContainer = new UINamingContainer();
    outerContainer.setId("outerContainer");
    form.getChildren().add(outerContainer);
    UINamingContainer innerContainer = new UINamingContainer();
    innerContainer.setId("innerContainer");
    outerContainer.getChildren().add(innerContainer);
    ArrayList<UIComponent> components = new ArrayList<>();
    components.add(outerContainer);
    components.add(innerContainer);
    SearchExpressionResolverFactory.registerResolver("@test", new TestMultiSearchExpressionResolver(components));
    List<UIComponent> result = resolveComponents(root, " @test ");
    assertTrue(result.size() == 2);
    assertTrue(result.contains(outerContainer));
    assertTrue(result.contains(innerContainer));
    SearchExpressionResolverFactory.removeResolver("@test");
}
Also used : UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) ArrayList(java.util.ArrayList) UIForm(javax.faces.component.UIForm) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Aggregations

UIComponent (javax.faces.component.UIComponent)57 UINamingContainer (javax.faces.component.UINamingContainer)57 UIForm (javax.faces.component.UIForm)56 Test (org.junit.jupiter.api.Test)56 UIPanel (javax.faces.component.UIPanel)55 UIOutput (javax.faces.component.UIOutput)49 UICommand (javax.faces.component.UICommand)47 ArrayList (java.util.ArrayList)3 InputText (org.primefaces.component.inputtext.InputText)3