Search in sources :

Example 41 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponent_Absolute.

@Test
public void resolveComponent_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);
    assertSame(source, resolveComponent(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 42 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveClientId_AbsoluteWithFormPrependIdFalse_InvokeOnComponent.

@Test
public void resolveClientId_AbsoluteWithFormPrependIdFalse_InvokeOnComponent() {
    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 43 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveClientId_AbsoluteNamingcontainerParent.

@Test
public void resolveClientId_AbsoluteNamingcontainerParent() {
    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("root", resolveClientId(source, " :form:outerContainer:@namingcontainer:@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 44 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveClientId_WidgetVarNext.

@Test
public void resolveClientId_WidgetVarNext() {
    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);
    InputText input2 = new InputText();
    input2.setId("input2");
    input2.setWidgetVar("myInput_Widget2");
    outerContainer.getChildren().add(input2);
    assertEquals(input2.getClientId(), resolveClientId(source, " @widgetVar(myInput_Widget):@next"));
}
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 45 with UINamingContainer

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

the class SearchExpressionFacadeTest method resolveComponent_Root.

@Test
public void resolveComponent_Root() {
    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);
    Assertions.assertEquals(FacesContext.getCurrentInstance().getViewRoot(), resolveComponent(form, " @root "));
}
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