Package org.apache.tapestry5.internal.structure

Examples of org.apache.tapestry5.internal.structure.ComponentPageElement


    }

    private void tryWithContext(final Object context, Object... expected)
    {
        Page page = mockPage();
        ComponentPageElement element = mockComponentPageElement();

        train_getRootElement(page, element);

        IAnswer answer = new IAnswer()
        {
            public Object answer() throws Throwable
            {
                Object[] args = EasyMock.getCurrentArguments();

                ComponentEventCallback callback = (ComponentEventCallback) args[2];

                return callback.handleResult(context);
            }
        };

        expect(element.triggerEvent(EasyMock.eq(EventConstants.PASSIVATE),
                                    (Object[]) EasyMock.isNull(),
                                    EasyMock.isA(ComponentEventCallback.class))).andAnswer(answer);

        replay();
View Full Code Here


        verify();
    }

    protected final void train_getBlock(Page page, String blockId, Block block)
    {
        ComponentPageElement element = mockComponentPageElement();
        train_getRootElement(page, element);

        expect(element.getBlock(blockId)).andReturn(block);
    }
View Full Code Here

        this.typeCoercer = typeCoercer;
    }

    public Object[] collectPageActivationContext(Page page)
    {
        ComponentPageElement element = page.getRootElement();

        final Holder<Object[]> holder = Holder.create();

        ComponentEventCallback callback = new ComponentEventCallback()
        {
            public boolean handleResult(Object result)
            {
                holder.put(typeCoercer.coerce(result, Object[].class));

                // We've got the value, stop the event.

                return true;
            }
        };

        element.triggerEvent(EventConstants.PASSIVATE, null, callback);

        if (!holder.hasValue()) return EMPTY;

        return holder.get();
    }
View Full Code Here

            mixinId = nestedId.substring(dollarx + 1);
            nestedId = nestedId.substring(0, dollarx);
        }


        ComponentPageElement element = page.getComponentElementByNestedId(nestedId);

        if (mixinId == null)
            return element.getComponent();

        ComponentResources resources = element.getMixinResources(mixinId);

        return resources.getComponent();
    }
View Full Code Here

        if (callback.isAborted()) return;

        Page containerPage = cache.get(parameters.getContainingPageName());

        ComponentPageElement element = containerPage.getComponentElementByNestedId(parameters.getNestedComponentId());

        environment.push(ComponentEventResultProcessor.class, resultProcessor);

        boolean handled = element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(),
                                                      callback);

        if (!handled)
            throw new TapestryException(ServicesMessages.eventNotHandled(element, parameters.getEventType()), element,
                                        null);
View Full Code Here

    @Test
    public void nested_element_within_page()
    {
        RequestPageCache cache = mockRequestPageCache();
        Page page = mockPage();
        ComponentPageElement element = mockComponentPageElement();
        Component component = mockComponent();
        ComponentClassResolver resolver = mockComponentClassResolver();

        train_get(cache, PAGE_NAME, page);
View Full Code Here

    @Test
    public void not_all_embedded_components_in_template()
    {
        ComponentTemplateSource templateSource = mockComponentTemplateSource();
        PageElementFactory elementFactory = mockPageElementFactory();
        ComponentPageElement rootElement = mockComponentPageElement();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentModel model = mockComponentModel();
        ComponentTemplate template = mockComponentTemplate();
        ComponentClassResolver resolver = mockComponentClassResolver();
        Location bazLocation = mockLocation();
View Full Code Here

    @Test
    public void type_conflict_between_template_and_class()
    {
        ComponentTemplateSource templateSource = mockComponentTemplateSource();
        PageElementFactory elementFactory = mockPageElementFactory();
        ComponentPageElement rootElement = mockComponentPageElement();
        InternalComponentResources resources = mockInternalComponentResources();
        ComponentModel model = mockComponentModel();
        ComponentTemplate template = mockComponentTemplate();
        EmbeddedComponentModel emodel = mockEmbeddedComponentModel();
        Location l = mockLocation();
View Full Code Here

        request.setAttribute(InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME, contentType);

        Page containerPage = cache.get(parameters.getContainingPageName());

        ComponentPageElement element = containerPage.getComponentElementByNestedId(parameters.getNestedComponentId());

        // In many cases, the triggered element is a Form that needs to be able to
        // pass its event handler return values to the correct result processor.
        // This is certainly the case for forms.

        TrackableComponentEventCallback callback = new ComponentResultProcessorWrapper(interceptor);

        environment.push(ComponentEventResultProcessor.class, interceptor);
        environment.push(TrackableComponentEventCallback.class, callback);

        boolean handled = element
                .triggerContextEvent(parameters.getEventType(), parameters.getEventContext(), callback);

        if (!handled)
            throw new TapestryException(String.format("Request event '%s' (on component %s) was not handled; you must provide a matching event handler method in the component or in one of its containers.", parameters.getEventType(), element.getCompleteId()), element,
                    null);

        environment.pop(TrackableComponentEventCallback.class);
        environment.pop(ComponentEventResultProcessor.class);
View Full Code Here

        request.setAttribute(InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME, contentType);

        Page containerPage = cache.get(parameters.getContainingPageName());

        ComponentPageElement element = containerPage.getComponentElementByNestedId(parameters.getNestedComponentId());

        // In many cases, the triggered element is a Form that needs to be able to
        // pass its event handler return values to the correct result processor.
        // This is certainly the case for forms.

        environment.push(ComponentEventResultProcessor.class, interceptor);

        boolean handled = element.triggerContextEvent(parameters.getEventType(), parameters.getEventContext(),
                                                      callback);

        if (!handled)
            throw new TapestryException(ServicesMessages.eventNotHandled(element, parameters.getEventType()), element,
                                        null);
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.internal.structure.ComponentPageElement

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.