Search in sources :

Example 1 with UINamingContainer

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

the class ComponentTraversalUtilsTest method closestForm.

@Test
public void closestForm() {
    UIForm outerForm = new UIForm();
    UIForm innerForm = new UIForm();
    UINamingContainer container = new UINamingContainer();
    UIComponent cmp = new UIOutput();
    innerForm.getChildren().add(cmp);
    container.getChildren().add(innerForm);
    outerForm.getChildren().add(container);
    UIComponent result = ComponentTraversalUtils.closestForm(null, cmp);
    assertSame(innerForm, result, "Expected closest surrounding UIForm");
}
Also used : UIOutput(javax.faces.component.UIOutput) UIComponent(javax.faces.component.UIComponent) UIForm(javax.faces.component.UIForm) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Example 2 with UINamingContainer

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

the class ComponentTraversalUtilsTest method closestNamingContainer.

@Test
public void closestNamingContainer() {
    UINamingContainer outerContainer = new UINamingContainer();
    UINamingContainer innerContainer = new UINamingContainer();
    UIForm form = new UIForm();
    UIComponent cmp = new UIOutput();
    innerContainer.getChildren().add(cmp);
    form.getChildren().add(innerContainer);
    outerContainer.getChildren().add(form);
    UIComponent result = ComponentTraversalUtils.closestNamingContainer(cmp);
    assertSame(innerContainer, result, "Expected closest surrounding UIForm");
}
Also used : UIOutput(javax.faces.component.UIOutput) UIComponent(javax.faces.component.UIComponent) UIForm(javax.faces.component.UIForm) UINamingContainer(javax.faces.component.UINamingContainer) Test(org.junit.jupiter.api.Test)

Example 3 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveClientId_Absolute.

@Test
public void resolveClientId_Absolute() {
    UIComponent root = new UIPanel();
    FacesContext.getCurrentInstance().getViewRoot().getChildren().add(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();
    innerContainer.getChildren().add(component);
    UIComponent source = new UICommand();
    source.setId("source");
    innerContainer.getChildren().add(source);
    assertEquals("form:outerContainer:innerContainer:source", resolveClientId(source, " :form:outerContainer:innerContainer:source "));
}
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 4 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponents_RelativeAndParent.

@Test
public void resolveComponents_RelativeAndParent() {
    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);
    List<UIComponent> resolvedComponents = resolveComponents(source, " other @parent");
    assertTrue(resolvedComponents.contains(component));
    assertTrue(resolvedComponents.contains(innerContainer));
    assertEquals(2, resolvedComponents.size());
}
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 5 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponent_Id.

public void resolveComponent_Id() {
    UIComponent root = new UIPanel();
    FacesContext.getCurrentInstance().getViewRoot().getChildren().add(root);
    UINamingContainer outerContainer = new UINamingContainer();
    outerContainer.setId("myContainer");
    root.getChildren().add(outerContainer);
    resolveComponent(root, " @id(myContainer) ");
}
Also used : UIComponent(javax.faces.component.UIComponent) UIPanel(javax.faces.component.UIPanel) UINamingContainer(javax.faces.component.UINamingContainer)

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