Package org.apache.tapestry5.internal.structure

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


        String pageName = "mypage";
        ComponentModel model = mockComponentModel();
        ComponentModelSource modelSource = mockComponentModelSource();
        RequestPageCache pageCache = mockRequestPageCache();
        Page page = mockPage();
        ComponentPageElement element = mockComponentPageElement();
        expect(modelSource.getPageModel(pageName)).andReturn(model);

        expect(model.handlesEvent(EventConstants.PASSIVATE)).andReturn(true);

        train_get(pageCache, pageName, page);

        train_getRootElement(page, element);

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

        replay();
View Full Code Here


    private void tryWithContext(String pageName, final Object context, Object... expected)
    {
        ComponentModelSource modelSource = mockComponentModelSource();
        RequestPageCache pageCache = mockRequestPageCache();
        ComponentPageElement element = mockComponentPageElement();
        ComponentModel model = mockComponentModel();
        Page page = mockPage();

        expect(modelSource.getPageModel(pageName)).andReturn(model);

        expect(model.handlesEvent(EventConstants.PASSIVATE)).andReturn(true);

        train_get(pageCache, pageName, page);

        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

        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

    {
        ComponentClassResolver resolver = mockComponentClassResolver();
        Request request = mockRequest();
        Response response = mockResponse();
        Page page = mockPage();
        ComponentPageElement rootElement = mockComponentPageElement();
        PageResponseRenderer renderer = mockPageResponseRenderer();
        RequestPageCache cache = mockRequestPageCache();
        ComponentEventResultProcessor processor = newComponentEventResultProcessor();
        LocalizationSetter ls = mockLocalizationSetter();
View Full Code Here

        RequestPageCache cache = mockRequestPageCache();
        ComponentEventResultProcessor processor = newComponentEventResultProcessor();
        Request request = mockRequest();
        Response response = mockResponse();
        Page page = mockPage();
        ComponentPageElement rootElement = mockComponentPageElement();
        LocalizationSetter ls = mockLocalizationSetter();

        String path = "/foo/Bar" + (finalSlash ? "/" : "");
        train_getPath(request, path);
View Full Code Here

        PageResponseRenderer renderer = mockPageResponseRenderer();
        RequestPageCache cache = mockRequestPageCache();
        Request request = mockRequest();
        Response response = mockResponse();
        Page page = mockPage();
        ComponentPageElement rootElement = mockComponentPageElement();
        LocalizationSetter ls = mockLocalizationSetter();

        String path = "/foo/Bar/zip/zoom" + (finalSlash ? "/" : "");
        train_getPath(request, path);
View Full Code Here

        request.setAttribute(InternalConstants.PAGE_NAME_ATTRIBUTE_NAME, parameters.getActivePageName());

        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

    void checkForRecursion(String componentClassName, Location location)
    {
        for (Object o : activeElement.getSnapshot())
        {
            ComponentPageElement e = (ComponentPageElement) o;

            if (e.getComponentResources().getComponentModel().getComponentClassName().equals(componentClassName))
            {
                throw new TapestryException(
                        String.format("The template for component %s is recursive (contains another direct or indirect reference to component %<s). This is not supported (components may not contain themselves).", componentClassName),
                        location,
                        null);
View Full Code Here

        // Get or create a page instance and trigger the event.

        Page page = requestPageCache.get(pageName);

        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

        RequestPageCache cache = mockRequestPageCache();
        ComponentEventResultProcessor processor = mockComponentEventResultProcessor();
        PageResponseRenderer renderer = mockPageResponseRenderer();
        Page page = mockPage();
        EventContext context = mockEventContext();
        ComponentPageElement root = mockComponentPageElement();
        InternalComponentResources pageResources = mockInternalComponentResources();
        PageActivator activator = newMock(PageActivator.class);
        Request request = mockRequest();
       
        train_getAttribute(request, InternalConstants.BYPASS_ACTIVATION, 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.