Search in sources :

Example 1 with HelloWorld

use of org.apache.myfaces.view.facelets.bean.HelloWorld in project myfaces by apache.

the class CompositeComponentClientBehaviorTestCase method testSimpleClientBehaviorDefaultAjaxWrap.

@Test
public void testSimpleClientBehaviorDefaultAjaxWrap() throws Exception {
    HelloWorld helloWorld = new HelloWorld();
    facesContext.getExternalContext().getRequestMap().put("helloWorldBean", helloWorld);
    UIViewRoot root = facesContext.getViewRoot();
    vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultAjaxWrap.xhtml");
    UIComponent form = root.findComponent("testForm1");
    Assert.assertNotNull(form);
    UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
    Assert.assertNotNull(compositeComponent);
    UICommand button = (UICommand) compositeComponent.findComponent("button");
    Assert.assertNotNull(button);
    Assert.assertNotNull(button.getClientBehaviors().get("dblclick"));
    Assert.assertEquals(1, button.getClientBehaviors().get("dblclick").size());
// StringWriter sw = new StringWriter();
// MockResponseWriter mrw = new MockResponseWriter(sw);
// facesContext.setResponseWriter(mrw);
// root.encodeAll(facesContext);
// sw.flush();
// System.out.print(sw.toString());
}
Also used : UIComponent(jakarta.faces.component.UIComponent) UICommand(jakarta.faces.component.UICommand) UINamingContainer(jakarta.faces.component.UINamingContainer) UIViewRoot(jakarta.faces.component.UIViewRoot) HelloWorld(org.apache.myfaces.view.facelets.bean.HelloWorld) Test(org.junit.Test)

Example 2 with HelloWorld

use of org.apache.myfaces.view.facelets.bean.HelloWorld in project myfaces by apache.

the class CompositeComponentClientBehaviorTestCase method testCompositeClientBehavior.

@Test
public void testCompositeClientBehavior() throws Exception {
    HelloWorld helloWorld = new HelloWorld();
    facesContext.getExternalContext().getRequestMap().put("helloWorldBean", helloWorld);
    UIViewRoot root = facesContext.getViewRoot();
    vdl.buildView(facesContext, root, "testCompositeClientBehavior.xhtml");
    UIComponent form = root.findComponent("testForm1");
    Assert.assertNotNull(form);
    UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
    Assert.assertNotNull(compositeComponent);
    UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("button3");
    Assert.assertNotNull(compositeComponent2);
    UICommand button = (UICommand) compositeComponent2.findComponent("button");
    Assert.assertNotNull(button);
    // One added in testCompositeActionSource, the other one
    // inside compositeActionSource.xhtml
    Assert.assertNotNull(button.getClientBehaviors().get("action"));
    Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
// StringWriter sw = new StringWriter();
// MockResponseWriter mrw = new MockResponseWriter(sw);
// facesContext.setResponseWriter(mrw);
// root.encodeAll(facesContext);
// sw.flush();
// System.out.print(sw.toString());
}
Also used : UIComponent(jakarta.faces.component.UIComponent) UICommand(jakarta.faces.component.UICommand) UINamingContainer(jakarta.faces.component.UINamingContainer) UIViewRoot(jakarta.faces.component.UIViewRoot) HelloWorld(org.apache.myfaces.view.facelets.bean.HelloWorld) Test(org.junit.Test)

Example 3 with HelloWorld

use of org.apache.myfaces.view.facelets.bean.HelloWorld in project myfaces by apache.

the class CompositeComponentClientBehaviorTestCase method testSimpleClientBehaviorDefaultNoEventAjaxWrap.

@Test
public void testSimpleClientBehaviorDefaultNoEventAjaxWrap() throws Exception {
    HelloWorld helloWorld = new HelloWorld();
    facesContext.getExternalContext().getRequestMap().put("helloWorldBean", helloWorld);
    UIViewRoot root = facesContext.getViewRoot();
    vdl.buildView(facesContext, root, "testSimpleClientBehaviorDefaultNoEventAjaxWrap.xhtml");
    UIComponent form = root.findComponent("testForm1");
    Assert.assertNotNull(form);
    UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
    Assert.assertNotNull(compositeComponent);
    UICommand button = (UICommand) compositeComponent.findComponent("button");
    Assert.assertNotNull(button);
    Assert.assertNotNull(button.getClientBehaviors().get("action"));
    Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
// StringWriter sw = new StringWriter();
// MockResponseWriter mrw = new MockResponseWriter(sw);
// facesContext.setResponseWriter(mrw);
// root.encodeAll(facesContext);
// sw.flush();
// System.out.print(sw.toString());
}
Also used : UIComponent(jakarta.faces.component.UIComponent) UICommand(jakarta.faces.component.UICommand) UINamingContainer(jakarta.faces.component.UINamingContainer) UIViewRoot(jakarta.faces.component.UIViewRoot) HelloWorld(org.apache.myfaces.view.facelets.bean.HelloWorld) Test(org.junit.Test)

Example 4 with HelloWorld

use of org.apache.myfaces.view.facelets.bean.HelloWorld in project myfaces by apache.

the class CompositeComponentClientBehaviorTestCase method testSimpleClientBehaviorAjaxWrap.

@Test
public void testSimpleClientBehaviorAjaxWrap() throws Exception {
    HelloWorld helloWorld = new HelloWorld();
    facesContext.getExternalContext().getRequestMap().put("helloWorldBean", helloWorld);
    UIViewRoot root = facesContext.getViewRoot();
    vdl.buildView(facesContext, root, "testSimpleClientBehaviorAjaxWrap.xhtml");
    UIComponent form = root.findComponent("testForm1");
    Assert.assertNotNull(form);
    UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
    Assert.assertNotNull(compositeComponent);
    UICommand button = (UICommand) compositeComponent.findComponent("button");
    Assert.assertNotNull(button);
    Assert.assertNotNull(button.getClientBehaviors().get("action"));
    Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
// StringWriter sw = new StringWriter();
// MockResponseWriter mrw = new MockResponseWriter(sw);
// facesContext.setResponseWriter(mrw);
// root.encodeAll(facesContext);
// sw.flush();
// System.out.print(sw.toString());
}
Also used : UIComponent(jakarta.faces.component.UIComponent) UICommand(jakarta.faces.component.UICommand) UINamingContainer(jakarta.faces.component.UINamingContainer) UIViewRoot(jakarta.faces.component.UIViewRoot) HelloWorld(org.apache.myfaces.view.facelets.bean.HelloWorld) Test(org.junit.Test)

Example 5 with HelloWorld

use of org.apache.myfaces.view.facelets.bean.HelloWorld in project myfaces by apache.

the class CompositeComponentClientBehaviorTestCase method testCompositeDoubleClientBehavior.

@Test
public void testCompositeDoubleClientBehavior() throws Exception {
    HelloWorld helloWorld = new HelloWorld();
    facesContext.getExternalContext().getRequestMap().put("helloWorldBean", helloWorld);
    UIViewRoot root = facesContext.getViewRoot();
    vdl.buildView(facesContext, root, "testCompositeDoubleClientBehavior.xhtml");
    UIComponent form = root.findComponent("testForm1");
    Assert.assertNotNull(form);
    UINamingContainer compositeComponent = (UINamingContainer) form.getChildren().get(0);
    Assert.assertNotNull(compositeComponent);
    UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("compositeClientBehavior");
    Assert.assertNotNull(compositeComponent2);
    UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent2.findComponent("button3");
    Assert.assertNotNull(compositeComponent3);
    UICommand button = (UICommand) compositeComponent3.findComponent("button");
    Assert.assertNotNull(button);
    // One added in testCompositeActionSource, the other one
    // inside compositeActionSource.xhtml
    Assert.assertNotNull(button.getClientBehaviors().get("action"));
    Assert.assertEquals(1, button.getClientBehaviors().get("action").size());
// StringWriter sw = new StringWriter();
// MockResponseWriter mrw = new MockResponseWriter(sw);
// facesContext.setResponseWriter(mrw);
// root.encodeAll(facesContext);
// sw.flush();
// System.out.print(sw.toString());
}
Also used : UIComponent(jakarta.faces.component.UIComponent) UICommand(jakarta.faces.component.UICommand) UINamingContainer(jakarta.faces.component.UINamingContainer) UIViewRoot(jakarta.faces.component.UIViewRoot) HelloWorld(org.apache.myfaces.view.facelets.bean.HelloWorld) Test(org.junit.Test)

Aggregations

UIViewRoot (jakarta.faces.component.UIViewRoot)33 HelloWorld (org.apache.myfaces.view.facelets.bean.HelloWorld)33 Test (org.junit.Test)33 UIComponent (jakarta.faces.component.UIComponent)31 UINamingContainer (jakarta.faces.component.UINamingContainer)24 UICommand (jakarta.faces.component.UICommand)14 StringWriter (java.io.StringWriter)12 MockResponseWriter (org.apache.myfaces.test.mock.MockResponseWriter)11 HtmlCommandLink (jakarta.faces.component.html.HtmlCommandLink)3 UIOutput (jakarta.faces.component.UIOutput)2 NavigationCase (jakarta.faces.application.NavigationCase)1 UIInput (jakarta.faces.component.UIInput)1 UIViewParameter (jakarta.faces.component.UIViewParameter)1 ResponseWriter (jakarta.faces.context.ResponseWriter)1 ViewMetadata (jakarta.faces.view.ViewMetadata)1 HashSet (java.util.HashSet)1 HtmlResponseWriterImpl (org.apache.myfaces.renderkit.html.HtmlResponseWriterImpl)1