Package org.apache.tapestry

Examples of org.apache.tapestry.IDirect


    public void test_Service_Simple_Event() throws Exception
    {
        Object[] parameters = new Object[0];
        IRequestCycle cycle = newCycle();
        IPage page = newPage();
        IDirect d = newDirect(false);
        LinkFactory lf = newLinkFactory();
        ResponseRenderer rr = newResponseRenderer();

        trainGetParameter(cycle, ServiceConstants.COMPONENT, "fred.barney");
        trainGetParameter(cycle, ServiceConstants.CONTAINER, null);
        trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
        trainGetParameter(cycle, ServiceConstants.SESSION, null);

        trainGetPage(cycle, "ActivePage", page);
        cycle.activate(page);

        trainGetNestedComponent(page, "fred.barney", d);

        trainExtractListenerParameters(lf, cycle, parameters);
       
        trainExtractBrowserEvent(cycle);
       
        cycle.setListenerParameters(isA(Object[].class));
       
        d.trigger(cycle);

        rr.renderResponse(cycle);

        replay();
View Full Code Here


    {
        Object[] parameters = new Object[0];
        IRequestCycle cycle = newCycle();
        IPage page = newPage();
        IPage componentPage = newPage();
        IDirect d = newDirect(false);
        LinkFactory lf = newLinkFactory();
        ResponseRenderer rr = newResponseRenderer();

        trainGetParameter(cycle, ServiceConstants.COMPONENT, "fred.barney");
        trainGetParameter(cycle, ServiceConstants.CONTAINER, "ComponentPage");
        trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
        trainGetParameter(cycle, ServiceConstants.SESSION, null);

        trainGetPage(cycle, "ActivePage", page);

        cycle.activate(page);

        trainGetPage(cycle, "ComponentPage", componentPage);

        trainGetNestedComponent(componentPage, "fred.barney", d);

        trainExtractListenerParameters(lf, cycle, parameters);
       
        expect(cycle.getParameter(BrowserEvent.NAME)).andReturn(null);
       
        cycle.setListenerParameters(parameters);

        d.trigger(cycle);

        rr.renderResponse(cycle);

        replay();
View Full Code Here

    public void testSessionActiveAndRequired() throws Exception
    {
        Object[] parameters = new Object[0];
        IRequestCycle cycle = newCycle();
        IPage page = newPage();
        IDirect d = newDirect(false);
       
        LinkFactory lf = newLinkFactory();
        ResponseRenderer rr = newResponseRenderer();

        trainGetParameter(cycle, ServiceConstants.COMPONENT, "fred.barney");
        trainGetParameter(cycle, ServiceConstants.CONTAINER, null);
        trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
        trainGetParameter(cycle, ServiceConstants.SESSION, "T");

        trainGetPage(cycle, "ActivePage", page);
        cycle.activate(page);

        trainGetNestedComponent(page, "fred.barney", d);

        trainIsStateful(d, true);

        WebSession session = newMock(WebSession.class);
        WebRequest request = newWebRequest(session);
       
        expect(session.isNew()).andReturn(false);
       
        trainExtractListenerParameters(lf, cycle, parameters);
       
        expect(cycle.getParameter(BrowserEvent.NAME)).andReturn(null);
       
        cycle.setListenerParameters(parameters);

        d.trigger(cycle);

        rr.renderResponse(cycle);

        replay();
View Full Code Here

    public void testStaleSession() throws Exception
    {
        IRequestCycle cycle = newCycle();
        IPage page = newPage();
        IDirect d = newDirect(false);
       
        Location l = newLocation();

        trainGetParameter(cycle, ServiceConstants.COMPONENT, "fred.barney");
        trainGetParameter(cycle, ServiceConstants.CONTAINER, null);
View Full Code Here

        IPage componentPage = componentPageName == null ? page : cycle.getPage(componentPageName);

        IComponent component = componentPage.getNestedComponent(componentId);

        IDirect direct = null;

        try
        {
            direct = (IDirect) component;
        }
        catch (ClassCastException ex)
        {
            throw new ApplicationRuntimeException(EngineMessages.wrongComponentType(
                    component,
                    IDirect.class), component, null, ex);
        }

        // Check for a StaleSession only when the session was stateful when
        // the link was created.

        if (activeSession && direct.isStateful())
        {
            WebSession session = _request.getSession(false);

            if (session == null || session.isNew())
                throw new StaleSessionException(EngineMessages.requestStateSession(direct),
View Full Code Here

public class TestDirectCallback extends BaseComponentTestCase
{
    public void testNoParams()
    {
        IPage page = newMock(IPage.class);
        IDirect component = newMock(IDirect.class);

        expect(component.getPage()).andReturn(page);

        expect(page.getPageName()).andReturn("Fred");

        expect(component.getIdPath()).andReturn("foo.bar");

        replay();

        DirectCallback callback = new DirectCallback(component, null);

        assertEquals("DirectCallback[Fred/foo.bar]", callback.toString());

        verify();

        IRequestCycle cycle = newCycleGetPage("Fred", page);

        expect(page.getNestedComponent("foo.bar")).andReturn(component);

        cycle.setListenerParameters(null);

        component.trigger(cycle);

        replay();

        callback.performCallback(cycle);
View Full Code Here

    {
        Object[] params = new Object[]
        { "p1", "p2" };

        IPage page = newMock(IPage.class);
        IDirect component = newMock(IDirect.class);

        expect(component.getPage()).andReturn(page);

        expect(page.getPageName()).andReturn("Barney");

        expect(component.getIdPath()).andReturn("foo.bar");

        replay();

        DirectCallback callback = new DirectCallback(component, params);

        assertEquals("DirectCallback[Barney/foo.bar p1, p2]", callback.toString());

        verify();

        IRequestCycle cycle = newCycleGetPage("Barney", page);

        expect(page.getNestedComponent("foo.bar")).andReturn(component);

        cycle.setListenerParameters(params);

        component.trigger(cycle);

        replay();

        callback.performCallback(cycle);
View Full Code Here

    }

    public void testNotDirect()
    {
        IPage page = newMock(IPage.class);
        IDirect component = newMock(IDirect.class);

        expect(component.getPage()).andReturn(page);

        expect(page.getPageName()).andReturn("Fred");
       
        expect(component.getIdPath()).andReturn("foo.bar");

        replay();

        DirectCallback callback = new DirectCallback(component, null);
View Full Code Here

    public void performCallback(IRequestCycle cycle)
    {
        IPage page = cycle.getPage(_pageName);
        IComponent component = page.getNestedComponent(_componentIdPath);
        IDirect direct = null;

        try
        {
            direct = (IDirect) component;
        }
        catch (ClassCastException ex)
        {
            throw new ApplicationRuntimeException(CallbackMessages.componentNotDirect(component),
                    component, null, ex);
        }

        cycle.setListenerParameters(_parameters);
        direct.trigger(cycle);
    }
View Full Code Here

    public void performCallback(IRequestCycle cycle)
    {
        IPage page = cycle.getPage(_pageName);
        IComponent component = page.getNestedComponent(_componentIdPath);
        IDirect direct = null;

        try
        {
            direct = (IDirect) component;
        }
        catch (ClassCastException ex)
        {
            throw new ApplicationRuntimeException(CallbackMessages.componentNotDirect(component),
                    component, null, ex);
        }

        cycle.setListenerParameters(_parameters);
        direct.trigger(cycle);
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.IDirect

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.