Search in sources :

Example 46 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponent_Form.

@Test
public void resolveComponent_Form() {
    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(form, resolveComponent(source, "@form"));
}
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 47 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponents_RelativeAndThisParent.

@Test
public void resolveComponents_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);
    List<UIComponent> resolvedComponents = resolveComponents(source, " other,@this:@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 48 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveClientId_AbsoluteWithFormPrependIdFalse_InvokeOnComponentSkipUnrendered.

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

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

the class SearchExpressionFacadeTest method resolveClientId_Parent.

@Test
public void resolveClientId_Parent() {
    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();
    innerContainer.getChildren().add(source);
    assertEquals("form:outerContainer:innerContainer", resolveClientId(source, " @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 50 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponents_Id_FromRoot.

@Test
public void resolveComponents_Id_FromRoot() {
    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);
    List<UIComponent> result = resolveComponents(innerContainer2, " @root:@id(myContainer) ");
    assertTrue(result.size() == 2);
    assertTrue(result.contains(outerContainer));
    assertTrue(result.contains(innerContainer));
}
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)

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