Package org.apache.tapestry5.runtime

Examples of org.apache.tapestry5.runtime.Component


    @Test
    public void cached_object_write() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        resources.writeParameter("object", "first");
        train_isRendering(resources, false);

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "second");
        train_isRendering(resources, false);

        replay();

        access.set(component, "object", "first");
        assertEquals(access.get(component, "object"), "second");

        verify();

        // Now try during rendering ...

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        resources.writeParameter("object", "third");
        train_isRendering(resources, true);

        replay();

        access.set(component, "object", "third");
        assertEquals(access.get(component, "object"), "third");

        verify();

        // And the cached value is lost after rendering is complete.

        train_isLoaded(resources, true);
        train_isBound(resources, "object", true);
        train_readParameter(resources, "object", String.class, "fourth");
        train_isRendering(resources, false);

        replay();

        component.postRenderCleanup();

        assertEquals(access.get(component, "object"), "fourth");

        verify();
    }
View Full Code Here


    @Test
    public void cached_primitive_write() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        resources.writeParameter("primitive", 321);

        train_isRendering(resources, false);

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        train_readParameter(resources, "primitive", Integer.class, 123);
        train_isRendering(resources, false);

        replay();

        access.set(component, "primitive", 321);
        assertEquals(access.get(component, "primitive"), 123);

        verify();

        // Now try during rendering ...

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        resources.writeParameter("primitive", 567);
        train_isRendering(resources, true);

        replay();

        access.set(component, "primitive", 567);
        assertEquals(access.get(component, "primitive"), 567);

        verify();

        // And the cached value is lost after rendering is complete.

        train_isLoaded(resources, true);
        train_isBound(resources, "primitive", true);
        train_readParameter(resources, "primitive", Integer.class, 890);
        train_isRendering(resources, false);

        replay();

        component.postRenderCleanup();

        assertEquals(access.get(component, "primitive"), 890);

        verify();
    }
View Full Code Here

    @Test
    public void uncached_object_read() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        // Notice no check for isRendering() since that is irrelevant to uncached parameters.
        // Also note difference between field name and parameter name, due to Parameter.name() being
        // specified.
View Full Code Here

    @Test
    public void uncached_object_write() throws Exception
    {
        InternalComponentResources resources = mockInternalComponentResources();

        Component component = setupForIntegrationTest(resources);

        // Notice no check for isRendering() since that is irrelevant to uncached parameters.
        // Also note difference between field name and parameter name, due to Parameter.name() being
        // specified.
View Full Code Here

                stub_isDebugEnabled(logger, false);
            }
        };

        Component component = setupForIntegrationTest(resources, logger, DefaultParameterComponent.class.getName(),
                                                      model, source, phaseTwoTraining);

        train_isLoaded(resources, true);
        train_isBound(resources, "value", true);
        train_readParameter(resources, "value", String.class, boundValue);
View Full Code Here

                stub_isDebugEnabled(logger, false);
            }
        };


        Component component = setupForIntegrationTest(resources, logger,
                                                      DefaultParameterBindingMethodComponent.class.getName(), model,
                                                      source, phaseTwoTraining);

        train_isLoaded(resources, true);
        train_isBound(resources, "value", true);
View Full Code Here

        transformation.finish();

        Instantiator instantiator = transformation.createInstantiator();

        Component component = instantiator.newInstance(resources);

        component.containingPageDidLoad();

        verify();

        return component;
    }
View Full Code Here

            if (logger.isDebugEnabled())
                logger.debug(String.format("Processing actions: %s", actionsBase64));

            ObjectInputStream ois = null;

            Component component = null;

            try
            {
                ois = new Base64ObjectInputStream(actionsBase64);

                while (true)
                {
                    String componentId = ois.readUTF();
                    ComponentAction action = (ComponentAction) ois.readObject();

                    component = source.getComponent(componentId);

                    if (logger.isDebugEnabled())
                        logger.debug(String.format("Processing: %s  %s", componentId, action));


                    action.execute(component);

                    component = null;
                }
            }
            catch (EOFException ex)
            {
                // Expected
            }
            catch (Exception ex)
            {
                Location location = component == null ? null : component.getComponentResources().getLocation();

                throw new TapestryException(ex.getMessage(), location, ex);
            }
            finally
            {
View Full Code Here

            logger.debug("Processing actions: {}", clientEncodedActions);

            ObjectInputStream ois = null;

            Component component = null;

            try
            {
                ois = clientDataEncoder.decodeClientData(clientEncodedActions);

                while (!eventCallback.isAborted())
                {
                    String componentId = ois.readUTF();
                    ComponentAction action = (ComponentAction) ois.readObject();

                    component = source.getComponent(componentId);

                    logger.debug("Processing: {} {}", componentId, action);

                    action.execute(component);

                    component = null;
                }
            } catch (EOFException ex)
            {
                // Expected
            } catch (Exception ex)
            {
                Location location = component == null ? null : component.getComponentResources().getLocation();

                throw new TapestryException(ex.getMessage(), location, ex);
            } finally
            {
                InternalUtils.close(ois);
View Full Code Here

            // See https://issues.apache.org/jira/browse/TAP5-1632
            javascriptSupport.allocateClientId(name);

        }

        Component activePage = componentSource.getActivePage();

        // This is unlikely but may be possible if people override some of the standard
        // exception reporting logic.

        if (activePage == null)
            return;

        ComponentResources activePageResources = activePage.getComponentResources();

        try
        {

            activePageResources.triggerEvent(EventConstants.PREALLOCATE_FORM_CONTROL_NAMES, new Object[]
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.runtime.Component

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.