Package javax.faces.component

Examples of javax.faces.component.UICommand$MethodExpressionAdapter


        //The first component has a default command button
        UIComponent form = root.findComponent("testForm1");
        Assert.assertNotNull(form);
        UINamingContainer compositeComponent1 = (UINamingContainer) form.findComponent("actionSource1");
        Assert.assertNotNull(compositeComponent1);
        UICommand button1 = (UICommand) compositeComponent1.findComponent("button");
        Assert.assertNotNull(button1);
        Assert.assertEquals("submit", button1.getActionExpression().invoke(facesContext.getELContext(), null));
       
        Assert.assertNotNull(button1.getActionListeners());
        Assert.assertEquals(1, button1.getActionListeners().length);
       
        UINamingContainer compositeComponent2 = (UINamingContainer) form.findComponent("actionSource2");
        Assert.assertNotNull(compositeComponent2);
        UICommand button2 = (UICommand) compositeComponent2.findComponent("button");
        Assert.assertNotNull(button2);
        //Since the button is outside cc:implementation, by the spec it cannot be taken into account as a valid "targets" value.
        Assert.assertEquals("fail", button2.getActionExpression().invoke(facesContext.getELContext(), null));
        //It also cannot be target of cc:actionSource
        Assert.assertNotNull(button2.getActionListeners());
        Assert.assertEquals(0, button2.getActionListeners().length);

        //StringWriter sw = new StringWriter();
        //MockResponseWriter mrw = new MockResponseWriter(sw);
        //facesContext.setResponseWriter(mrw);
       
View Full Code Here


       
        UIComponent panelGroup1 = root.findComponent("testGroup1");
        Assert.assertNotNull(panelGroup1);
        UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent1);
        UICommand button1 = (UICommand) compositeComponent1.findComponent("testComponent");
        Assert.assertNotNull(button1);
        Assert.assertNotNull(button1.getActionListeners());
        Assert.assertEquals(1, button1.getActionListeners().length);
       
        bean.setActionListener1Called(false);
        button1.getActionListeners()[0].processAction(new ActionEvent(button1));
        Assert.assertTrue(bean.isActionListener1Called());

        UIComponent panelGroup2 = root.findComponent("testGroup2");
        Assert.assertNotNull(panelGroup2);
        UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0);
        Assert.assertNotNull(compositeComponent2);
        UICommand button2 = (UICommand) compositeComponent2.findComponent("testComponent");
        Assert.assertNotNull(button2);
        Assert.assertNotNull(button2.getActionListeners());
        Assert.assertEquals(1, button2.getActionListeners().length);
       
        bean.setActionListener2Called(false);
        button2.getActionListeners()[0].processAction(new ActionEvent(button2));
        Assert.assertTrue(bean.isActionListener2Called());
    }
View Full Code Here

        UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent1);
       
        UINamingContainer compositeComponent1inner = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget");
        Assert.assertNotNull(compositeComponent1inner);
        UICommand button1 = (UICommand) compositeComponent1inner.findComponent("testComponent");
        Assert.assertNotNull(button1);
        Assert.assertNotNull(button1.getActionListeners());
        Assert.assertEquals(1, button1.getActionListeners().length);
       
        bean.setActionListener1Called(false);
        button1.getActionListeners()[0].processAction(new ActionEvent(button1));
        Assert.assertTrue(bean.isActionListener1Called());

        UIComponent panelGroup2 = root.findComponent("testGroup2");
        Assert.assertNotNull(panelGroup2);
        UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0);
        Assert.assertNotNull(compositeComponent2);
       
        UINamingContainer compositeComponent2inner = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionTarget");
        Assert.assertNotNull(compositeComponent2inner);
        UICommand button2 = (UICommand) compositeComponent2inner.findComponent("testComponent");
        Assert.assertNotNull(button2);
        Assert.assertNotNull(button2.getActionListeners());
        Assert.assertEquals(1, button2.getActionListeners().length);
       
        bean.setActionListener2Called(false);
        button2.getActionListeners()[0].processAction(new ActionEvent(button2));
        Assert.assertTrue(bean.isActionListener2Called());

    }
View Full Code Here

       
        UIComponent panelGroup1 = root.findComponent("testGroup1");
        Assert.assertNotNull(panelGroup1);
        UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent1);
        UICommand button1 = (UICommand) compositeComponent1.findComponent("testComponent");
        Assert.assertNotNull(button1);
        Assert.assertNotNull(button1.getActionListeners());
        Assert.assertEquals(1, button1.getActionListeners().length);
       
        bean.setActionListener1Called(false);
        button1.getActionListeners()[0].processAction(new ActionEvent(button1));
        Assert.assertTrue(bean.isActionListener1Called());
       
        UICommand button1n = (UICommand) compositeComponent1.findComponent("testComponentNoTarget");
       
        Assert.assertNotNull(button1n);
        Assert.assertNotNull(button1n.getActionListeners());
        Assert.assertEquals(1, button1n.getActionListeners().length);
       
        compositeComponent1.pushComponentToEL(facesContext, compositeComponent1);
        bean.setActionListener1Called(false);
        button1n.getActionListeners()[0].processAction(new ActionEvent(button1n));
        Assert.assertTrue(bean.isActionListener1Called());
        compositeComponent1.popComponentFromEL(facesContext);
       
        UIComponent panelGroup2 = root.findComponent("testGroup2");
        Assert.assertNotNull(panelGroup2);
        UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0);
        Assert.assertNotNull(compositeComponent2);
        UICommand button2 = (UICommand) compositeComponent2.findComponent("testComponent");
        Assert.assertNotNull(button2);
        Assert.assertNotNull(button2.getActionListeners());
        Assert.assertEquals(1, button2.getActionListeners().length);
       
        bean.setActionListener2Called(false);
        button2.getActionListeners()[0].processAction(new ActionEvent(button2));
        Assert.assertTrue(bean.isActionListener2Called());
       
        UICommand button2n = (UICommand) compositeComponent2.findComponent("testComponentNoTarget");
       
        Assert.assertNotNull(button2n);
        Assert.assertNotNull(button2n.getActionListeners());
        Assert.assertEquals(1, button2n.getActionListeners().length);
       
        compositeComponent2.pushComponentToEL(facesContext, compositeComponent2);
        bean.setActionListener2Called(false);
        button2n.getActionListeners()[0].processAction(new ActionEvent(button2n));
        Assert.assertTrue(bean.isActionListener2Called());
        compositeComponent2.popComponentFromEL(facesContext);
    }
View Full Code Here

        UINamingContainer compositeComponent1 = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent1);
       
        UINamingContainer compositeComponent1target = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionTarget");
        Assert.assertNotNull(compositeComponent1target);
        UICommand button1target = (UICommand) compositeComponent1target.findComponent("testComponent");
        Assert.assertNotNull(button1target);
        Assert.assertNotNull(button1target.getActionListeners());
        Assert.assertEquals(1, button1target.getActionListeners().length);
       
        bean.setActionListener1Called(false);
        button1target.getActionListeners()[0].processAction(new ActionEvent(button1target));
        Assert.assertTrue(bean.isActionListener1Called());

        UICommand button1notarget = (UICommand) compositeComponent1target.findComponent("testComponentNoTarget");
        Assert.assertNotNull(button1notarget);
        Assert.assertNotNull(button1notarget.getActionListeners());
        Assert.assertEquals(1, button1notarget.getActionListeners().length);
       
        compositeComponent1.pushComponentToEL(facesContext, compositeComponent1);
        compositeComponent1target.pushComponentToEL(facesContext, compositeComponent1target);
        bean.setActionListener1Called(false);
        button1notarget.getActionListeners()[0].processAction(new ActionEvent(button1notarget));
        Assert.assertTrue(bean.isActionListener1Called());
        compositeComponent1target.popComponentFromEL(facesContext);
        compositeComponent1.popComponentFromEL(facesContext);
       
        UINamingContainer compositeComponent1notarget = (UINamingContainer) compositeComponent1.findComponent("simpleAttributeMethodExpressionNoTarget");
        Assert.assertNotNull(compositeComponent1notarget);
        UICommand buttonnotarget1target = (UICommand) compositeComponent1notarget.findComponent("testComponent");
        Assert.assertNotNull(buttonnotarget1target);
        Assert.assertNotNull(buttonnotarget1target.getActionListeners());
        Assert.assertEquals(1, buttonnotarget1target.getActionListeners().length);
       
        compositeComponent1.pushComponentToEL(facesContext, compositeComponent1);
        compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget);
        bean.setActionListener1Called(false);
        buttonnotarget1target.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget1target));
        Assert.assertTrue(bean.isActionListener1Called());
        compositeComponent1notarget.popComponentFromEL(facesContext);
        compositeComponent1.popComponentFromEL(facesContext);
       
        UICommand buttonnotarget1notarget = (UICommand) compositeComponent1notarget.findComponent("testComponentNoTarget");
        Assert.assertNotNull(buttonnotarget1notarget);
        Assert.assertNotNull(buttonnotarget1notarget.getActionListeners());
        Assert.assertEquals(1, buttonnotarget1notarget.getActionListeners().length);
        compositeComponent1.pushComponentToEL(facesContext, compositeComponent1);
        compositeComponent1notarget.pushComponentToEL(facesContext, compositeComponent1notarget);
        bean.setActionListener1Called(false);
        buttonnotarget1notarget.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget1notarget));
        Assert.assertTrue(bean.isActionListener1Called());
        compositeComponent1notarget.popComponentFromEL(facesContext);
        compositeComponent1.popComponentFromEL(facesContext);
       
        UIComponent panelGroup2 = root.findComponent("testGroup2");
        Assert.assertNotNull(panelGroup2);
        UINamingContainer compositeComponent2 = (UINamingContainer) panelGroup2.getChildren().get(0);
        Assert.assertNotNull(compositeComponent2);
       
        UINamingContainer compositeComponent2target = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionTarget");
        Assert.assertNotNull(compositeComponent2target);
        UICommand button2target = (UICommand) compositeComponent2target.findComponent("testComponent");
        Assert.assertNotNull(button2target);
        Assert.assertNotNull(button2target.getActionListeners());
        Assert.assertEquals(1, button2target.getActionListeners().length);
       
        bean.setActionListener2Called(false);
        button2target.getActionListeners()[0].processAction(new ActionEvent(button2target));
        Assert.assertTrue(bean.isActionListener2Called());

        UICommand button2notarget = (UICommand) compositeComponent2target.findComponent("testComponentNoTarget");
        Assert.assertNotNull(button2notarget);
        Assert.assertNotNull(button2notarget.getActionListeners());
        Assert.assertEquals(1, button2notarget.getActionListeners().length);
       
        compositeComponent2.pushComponentToEL(facesContext, compositeComponent2);
        compositeComponent2target.pushComponentToEL(facesContext, compositeComponent2target);
        bean.setActionListener2Called(false);
        button2notarget.getActionListeners()[0].processAction(new ActionEvent(button2notarget));
        Assert.assertTrue(bean.isActionListener2Called());
        compositeComponent2target.popComponentFromEL(facesContext);
        compositeComponent2.popComponentFromEL(facesContext);
       
        UINamingContainer compositeComponent2notarget = (UINamingContainer) compositeComponent2.findComponent("simpleAttributeMethodExpressionNoTarget");
        Assert.assertNotNull(compositeComponent2notarget);
        UICommand buttonnotarget2target = (UICommand) compositeComponent2notarget.findComponent("testComponent");
        Assert.assertNotNull(buttonnotarget2target);
        Assert.assertNotNull(buttonnotarget2target.getActionListeners());
        Assert.assertEquals(1, buttonnotarget2target.getActionListeners().length);
       
        compositeComponent2.pushComponentToEL(facesContext, compositeComponent2);
        compositeComponent2notarget.pushComponentToEL(facesContext, compositeComponent2notarget);
        bean.setActionListener2Called(false);
        buttonnotarget2target.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget2target));
        Assert.assertTrue(bean.isActionListener2Called());
        compositeComponent2notarget.popComponentFromEL(facesContext);
        compositeComponent2.popComponentFromEL(facesContext);
       
        UICommand buttonnotarget2notarget = (UICommand) compositeComponent2notarget.findComponent("testComponentNoTarget");
        Assert.assertNotNull(buttonnotarget2notarget);
        Assert.assertNotNull(buttonnotarget2notarget.getActionListeners());
        Assert.assertEquals(1, buttonnotarget2notarget.getActionListeners().length);
        compositeComponent2.pushComponentToEL(facesContext, compositeComponent2);
        compositeComponent2notarget.pushComponentToEL(facesContext, compositeComponent2notarget);
        bean.setActionListener2Called(false);
        buttonnotarget2notarget.getActionListeners()[0].processAction(new ActionEvent(buttonnotarget2notarget));
        Assert.assertTrue(bean.isActionListener2Called());
        compositeComponent2notarget.popComponentFromEL(facesContext);
        compositeComponent2.popComponentFromEL(facesContext);
    }
View Full Code Here

       
        UIComponent panelGroup1 = root.findComponent("testGroup1");
        Assert.assertNotNull(panelGroup1);
        UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
        UICommand testComponent = (UICommand) compositeComponent.findComponent("testComponent");
        Assert.assertNotNull(testComponent);
        Assert.assertNotNull(testComponent.getActionExpression());
        Assert.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null));
    }
View Full Code Here

        UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
       
        UINamingContainer compositeComponent2 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeMethodExpressionTarget");
        Assert.assertNotNull(compositeComponent2);
        UICommand testComponent = (UICommand) compositeComponent2.findComponent("testComponent");
        Assert.assertNotNull(testComponent);
        Assert.assertNotNull(testComponent.getActionExpression());
        Assert.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null));
    }
View Full Code Here

       
        UIComponent panelGroup1 = root.findComponent("testGroup1");
        Assert.assertNotNull(panelGroup1);
        UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
        UICommand button = (UICommand) compositeComponent.findComponent("testComponentNoTarget");
        Assert.assertNotNull(button);
       
        compositeComponent.pushComponentToEL(facesContext, compositeComponent);
        button.pushComponentToEL(facesContext,  button);
        MethodExpression method = button.getActionExpression();
        Assert.assertEquals(bean.doSomeAction(), method.invoke(facesContext.getELContext(), null));
        button.popComponentFromEL(facesContext);
        compositeComponent.popComponentFromEL(facesContext);

    }
View Full Code Here

        UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
       
        UINamingContainer compositeComponent3 = (UINamingContainer) compositeComponent.findComponent("simpleAttributeActionMethodExpressionNoTarget");
        Assert.assertNotNull(compositeComponent3);
        UICommand testComponentNoTarget3 = (UICommand) compositeComponent3.findComponent("testComponentNoTarget");
        Assert.assertNotNull(testComponentNoTarget3);
        Assert.assertNotNull(testComponentNoTarget3.getActionExpression());
        compositeComponent.pushComponentToEL(facesContext, compositeComponent);
        compositeComponent.pushComponentToEL(facesContext, compositeComponent3);
        Assert.assertEquals(bean.doSomeAction(), testComponentNoTarget3.getActionExpression().invoke(facesContext.getELContext(), null));
        compositeComponent3.popComponentFromEL(facesContext);
        compositeComponent.popComponentFromEL(facesContext);
    }
View Full Code Here

       
        UIComponent panelGroup1 = root.findComponent("testGroup1");
        Assert.assertNotNull(panelGroup1);
        UINamingContainer compositeComponent = (UINamingContainer) panelGroup1.getChildren().get(0);
        Assert.assertNotNull(compositeComponent);
        UICommand testComponent = (UICommand) compositeComponent.findComponent("testComponent");
        Assert.assertNotNull(testComponent);
        Assert.assertNotNull(testComponent.getActionExpression());
        Assert.assertEquals(bean.doSomeAction(), testComponent.getActionExpression().invoke(facesContext.getELContext(), null));
       
        UICommand testComponentNoTarget = (UICommand) compositeComponent.findComponent("testComponentNoTarget");
        Assert.assertNotNull(testComponentNoTarget);
        Assert.assertNotNull(testComponentNoTarget.getActionExpression());
        compositeComponent.pushComponentToEL(facesContext, compositeComponent);
        Assert.assertEquals(bean.doSomeAction(), testComponentNoTarget.getActionExpression().invoke(facesContext.getELContext(), null));
        compositeComponent.popComponentFromEL(facesContext);
    }
View Full Code Here

TOP

Related Classes of javax.faces.component.UICommand$MethodExpressionAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.