Search in sources :

Example 36 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveClientId_This.

@Test
public void resolveClientId_This() {
    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();
    innerContainer.getChildren().add(component);
    UIComponent source = new UICommand();
    source.setId("source");
    innerContainer.getChildren().add(source);
    assertEquals("form:outerContainer:innerContainer:source", resolveClientId(source, " @this "));
}
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 37 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponent_WidgetVar.

@Test
public void resolveComponent_WidgetVar() {
    UIComponent root = new UIPanel();
    FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root);
    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);
    InputText input = new InputText();
    input.setWidgetVar("myInput_Widget");
    outerContainer.getChildren().add(input);
    assertEquals(input, resolveComponent(source, " @widgetVar(myInput_Widget)"));
}
Also used : UIOutput(javax.faces.component.UIOutput) InputText(org.primefaces.component.inputtext.InputText) 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 38 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponents_Id.

@Test
public void resolveComponents_Id() {
    UIComponent root = new UIPanel();
    FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root);
    UINamingContainer outerContainer = new UINamingContainer();
    outerContainer.setId("myContainer");
    root.getChildren().add(outerContainer);
    UIForm form = new UIForm();
    form.setId("form");
    root.getChildren().add(form);
    UINamingContainer innerContainer = new UINamingContainer();
    innerContainer.setId("myContainer");
    form.getChildren().add(innerContainer);
    UINamingContainer innerContainer2 = new UINamingContainer();
    innerContainer2.setId("myContainer2");
    form.getChildren().add(innerContainer2);
    UINamingContainer innerContainer3 = new UINamingContainer();
    innerContainer3.setId("myContainer3-test");
    form.getChildren().add(innerContainer3);
    List<UIComponent> result = resolveComponents(form, " @id(myContainer) ");
    assertTrue(result.size() == 1);
    assertTrue(result.contains(innerContainer));
    result = resolveComponents(form, " @id(myContainer3-test) ");
    assertTrue(result.size() == 1);
    assertTrue(result.contains(innerContainer3));
}
Also used : UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) UIForm(javax.faces.component.UIForm) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Example 39 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponents_SimpleMultiSearchExpressionResolver_Parent.

@Test
public void resolveComponents_SimpleMultiSearchExpressionResolver_Parent() {
    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 ");
    assertTrue(result.size() == 2);
    assertTrue(result.contains(outerContainer));
    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 40 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveClientId_Namingcontainer.

@Test
public void resolveClientId_Namingcontainer() {
    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();
    innerContainer.getChildren().add(component);
    UIComponent source = new UICommand();
    source.setId("source");
    innerContainer.getChildren().add(source);
    assertEquals("form:outerContainer:innerContainer", resolveClientId(source, " @namingcontainer "));
}
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)

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