Search in sources :

Example 1 with UIPanel

use of jakarta.faces.component.UIPanel in project myfaces by apache.

the class UIComponentFindComponentTest method testRelativeExpression.

public void testRelativeExpression() throws Exception {
    String expression = "testimpl";
    UIComponent namingContainer = new UINamingContainer();
    UIComponent parent = new UIPanel();
    namingContainer.setId("namingContainer");
    namingContainer.getChildren().add(parent);
    parent.setId("parent");
    parent.getChildren().add(_testImpl);
    _testImpl.setId("testimpl");
    Assert.assertEquals(_testImpl, _testImpl.findComponent(expression));
}
Also used : UIComponent(jakarta.faces.component.UIComponent) UIPanel(jakarta.faces.component.UIPanel) UINamingContainer(jakarta.faces.component.UINamingContainer)

Example 2 with UIPanel

use of jakarta.faces.component.UIPanel in project myfaces by apache.

the class UIComponentBaseGetChildrenTest method testSetFacetClearChild.

/**
 * Whenever an existing child component is removed, the parent
 * property of the child must be set to null.
 */
public void testSetFacetClearChild() {
    UIInput input = new UIInput();
    input.setId("input0");
    UIInput input1 = new UIInput();
    input.setId("input1");
    UIPanel panel = new UIPanel();
    panel.getChildren().add(input);
    Assert.assertEquals(panel, input.getParent());
    UIViewRoot root = new UIViewRoot();
    root.getChildren().add(panel);
    root.getFacets().put("customFacet", input1);
    root.getFacets().put("customFacet", input);
    Assert.assertEquals(root, input.getParent());
    Assert.assertNull(input1.getParent());
    Assert.assertFalse(root.getFacets().isEmpty());
    Assert.assertTrue(panel.getChildCount() == 0);
}
Also used : UIPanel(jakarta.faces.component.UIPanel) UIInput(jakarta.faces.component.UIInput) UIViewRoot(jakarta.faces.component.UIViewRoot)

Example 3 with UIPanel

use of jakarta.faces.component.UIPanel in project myfaces by apache.

the class UIComponentBaseGetChildrenTest method testSimpleAddRemove.

public void testSimpleAddRemove() {
    UIInput input = new UIInput();
    input.setId("input0");
    UIPanel panel = new UIPanel();
    panel.getChildren().add(input);
    Assert.assertEquals(panel, input.getParent());
    panel.getChildren().remove(input);
    Assert.assertNull(input.getParent());
}
Also used : UIPanel(jakarta.faces.component.UIPanel) UIInput(jakarta.faces.component.UIInput)

Example 4 with UIPanel

use of jakarta.faces.component.UIPanel in project myfaces by apache.

the class UIComponentBaseGetChildrenTest method testSetChild2.

public void testSetChild2() {
    UIInput input = new UIInput();
    input.setId("input0");
    UIInput input1 = new UIInput();
    input.setId("input1");
    UIPanel panel = new UIPanel();
    panel.getChildren().add(input);
    Assert.assertEquals(panel, input.getParent());
    UIViewRoot root = new UIViewRoot();
    root.getChildren().add(panel);
    root.getFacets().put("customFacet", input1);
    panel.getChildren().set(0, input1);
    Assert.assertEquals(panel, input1.getParent());
    Assert.assertNull(input.getParent());
    Assert.assertTrue(root.getFacets().isEmpty());
}
Also used : UIPanel(jakarta.faces.component.UIPanel) UIInput(jakarta.faces.component.UIInput) UIViewRoot(jakarta.faces.component.UIViewRoot)

Example 5 with UIPanel

use of jakarta.faces.component.UIPanel in project myfaces by apache.

the class UIComponentBaseGetChildrenTest method testSetFacetClearFacet.

public void testSetFacetClearFacet() {
    UIInput input = new UIInput();
    input.setId("input0");
    UIInput input1 = new UIInput();
    input.setId("input1");
    UIPanel panel = new UIPanel();
    panel.getFacets().put("header", input);
    Assert.assertEquals(panel, input.getParent());
    UIViewRoot root = new UIViewRoot();
    root.getChildren().add(panel);
    root.getFacets().put("customFacet", input1);
    root.getFacets().put("customFacet", input);
    Assert.assertEquals(root, input.getParent());
    Assert.assertNull(input1.getParent());
    Assert.assertFalse(root.getFacets().isEmpty());
    Assert.assertTrue(panel.getChildCount() == 0);
}
Also used : UIPanel(jakarta.faces.component.UIPanel) UIInput(jakarta.faces.component.UIInput) UIViewRoot(jakarta.faces.component.UIViewRoot)

Aggregations

UIPanel (jakarta.faces.component.UIPanel)78 Test (org.junit.Test)53 FacesContext (jakarta.faces.context.FacesContext)39 UIViewRoot (jakarta.faces.component.UIViewRoot)20 UIComponent (jakarta.faces.component.UIComponent)15 Locale (java.util.Locale)11 ViewPoolProcessor (org.apache.myfaces.view.facelets.ViewPoolProcessor)11 UICommand (jakarta.faces.component.UICommand)9 UIInput (jakarta.faces.component.UIInput)7 UINamingContainer (jakarta.faces.component.UINamingContainer)6 BigIntegerConverter (jakarta.faces.convert.BigIntegerConverter)6 DoubleConverter (jakarta.faces.convert.DoubleConverter)6 FloatConverter (jakarta.faces.convert.FloatConverter)6 IntegerConverter (jakarta.faces.convert.IntegerConverter)6 LongConverter (jakarta.faces.convert.LongConverter)6 ShortConverter (jakarta.faces.convert.ShortConverter)6 FaceletState (org.apache.myfaces.view.facelets.tag.faces.FaceletState)6 VariableMapper (jakarta.el.VariableMapper)3 FacesException (jakarta.faces.FacesException)3 UIForm (jakarta.faces.component.UIForm)3