Package org.apache.tapestry

Examples of org.apache.tapestry.IDirect


    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


        // must implement both interfaces
        if (!ILinkComponent.class.isInstance(component)
                || !IDirect.class.isInstance(component))
            return;
       
        IDirect direct = (IDirect)component;
       
        // check for dynamic parameters
        if (!direct.isAsync() && !direct.isJson())
            return;
       
        PageRenderSupport prs = TapestryUtils.getPageRenderSupport(cycle, component);
       
        if (prs == null)
            return;
       
        Map parms = new HashMap();
       
        parms.put("component", component);
        parms.put("json", Boolean.valueOf(direct.isJson()));
       
        // execute script template
        _scriptSource.getScript(_script).execute(cycle, prs, parms);
    }
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(Tapestry.format(
                    "DirectCallback.wrong-type",
                    component.getExtendedId()), component, null, ex);
        }

        cycle.setListenerParameters(_parameters);
        direct.trigger(cycle);
    }
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

        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),
                        componentPage);
        }

        Object[] parameters = _linkFactory.extractListenerParameters(cycle);

        cycle.setListenerParameters(parameters);

        direct.trigger(cycle);

        // Render the response. This will be the active page
        // unless the direct component (or its delegate) changes it.

        _responseRenderer.renderResponse(cycle);
View Full Code Here

    public void testGetLinkOnSamePage()
    {
        IPage page = newPage("ThePage");

        MockControl cc = newControl(IDirect.class);
        IDirect c = (IDirect) cc.getMock();

        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        WebRequest request = newWebRequest(false, null);

        cycle.getPage();
        cyclec.setReturnValue(page);

        c.getPage();
        cc.setReturnValue(page);

        c.getIdPath();
        cc.setReturnValue("fred.barney");

        Object[] serviceParameters = new Object[0];

        Map parameters = new HashMap();
View Full Code Here

    {
        IPage page = newPage("ThePage");
        WebRequest request = newWebRequest(false, newWebSession());

        MockControl cc = newControl(IDirect.class);
        IDirect c = (IDirect) cc.getMock();

        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        cycle.getPage();
        cyclec.setReturnValue(page);

        c.getPage();
        cc.setReturnValue(page);

        c.getIdPath();
        cc.setReturnValue("fred.barney");

        Object[] serviceParameters = new Object[0];

        Map parameters = new HashMap();
View Full Code Here

    {
        IPage page = newPage("ActivePage");
        IPage componentPage = newPage("ComponentPage");
        WebRequest request = newWebRequest(false, null);
        MockControl cc = newControl(IDirect.class);
        IDirect c = (IDirect) cc.getMock();

        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        cycle.getPage();
        cyclec.setReturnValue(page);

        c.getPage();
        cc.setReturnValue(componentPage);

        c.getIdPath();
        cc.setReturnValue("fred.barney");

        Object[] serviceParameters = new Object[0];

        Map parameters = new HashMap();
View Full Code Here

        cyclec.setReturnValue(page);

        cycle.activate(page);

        MockControl dc = newControl(IDirect.class);
        IDirect d = (IDirect) dc.getMock();

        page.getNestedComponent("fred.barney");
        pagec.setReturnValue(d);

        MockControl lfc = newControl(LinkFactory.class);
        LinkFactory lf = (LinkFactory) lfc.getMock();

        lf.extractListenerParameters(cycle);
        lfc.setReturnValue(parameters);

        cycle.setListenerParameters(parameters);

        d.trigger(cycle);

        ResponseRenderer rr = newResponseRenderer();

        rr.renderResponse(cycle);
View Full Code Here

        cycle.getPage("ComponentPage");
        cyclec.setReturnValue(componentPage);

        MockControl dc = newControl(IDirect.class);
        IDirect d = (IDirect) dc.getMock();

        componentPage.getNestedComponent("fred.barney");
        componentPagec.setReturnValue(d);

        MockControl lfc = newControl(LinkFactory.class);
        LinkFactory lf = (LinkFactory) lfc.getMock();

        lf.extractListenerParameters(cycle);
        lfc.setReturnValue(parameters);

        cycle.setListenerParameters(parameters);

        d.trigger(cycle);

        ResponseRenderer rr = newResponseRenderer();

        rr.renderResponse(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.