Search in sources :

Example 1 with Handle

use of org.apache.tapestry5.internal.plastic.asm.Handle in project tapestry-5 by apache.

the class PageRenderRequestHandlerImpl method handle.

public void handle(PageRenderRequestParameters parameters) throws IOException {
    Page page = cache.get(parameters.getLogicalPageName());
    if (request.getAttribute(InternalConstants.BYPASS_ACTIVATION) == null) {
        if (pageActivator.activatePage(page.getRootElement().getComponentResources(), parameters.getActivationContext(), resultProcessor)) {
            return;
        }
        if (!parameters.isLoopback()) {
            page.pageReset();
        }
    }
    pageResponseRenderer.renderPageResponse(page);
}
Also used : Page(org.apache.tapestry5.internal.structure.Page)

Example 2 with Handle

use of org.apache.tapestry5.internal.plastic.asm.Handle in project tapestry-5 by apache.

the class AjaxFilter method handle.

public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler) throws IOException {
    ComponentEventRequestHandler next = request.isXHR() ? ajaxHandler : handler;
    next.handle(parameters);
}
Also used : ComponentEventRequestHandler(org.apache.tapestry5.services.ComponentEventRequestHandler)

Example 3 with Handle

use of org.apache.tapestry5.internal.plastic.asm.Handle in project tapestry-5 by apache.

the class Remapper method mapValue.

/**
 * Returns the given value, remapped with this remapper. Possible values are {@link Boolean},
 * {@link Byte}, {@link Short}, {@link Character}, {@link Integer}, {@link Long}, {@link Double},
 * {@link Float}, {@link String}, {@link Type}, {@link Handle}, {@link ConstantDynamic} or arrays
 * of primitive types .
 *
 * @param value an object. Only {@link Type}, {@link Handle} and {@link ConstantDynamic} values
 *     are remapped.
 * @return the given value, remapped with this remapper.
 */
public Object mapValue(final Object value) {
    if (value instanceof Type) {
        return mapType((Type) value);
    }
    if (value instanceof Handle) {
        Handle handle = (Handle) value;
        return new Handle(handle.getTag(), mapType(handle.getOwner()), mapMethodName(handle.getOwner(), handle.getName(), handle.getDesc()), handle.getTag() <= Opcodes.H_PUTSTATIC ? mapDesc(handle.getDesc()) : mapMethodDesc(handle.getDesc()), handle.isInterface());
    }
    if (value instanceof ConstantDynamic) {
        ConstantDynamic constantDynamic = (ConstantDynamic) value;
        int bootstrapMethodArgumentCount = constantDynamic.getBootstrapMethodArgumentCount();
        Object[] remappedBootstrapMethodArguments = new Object[bootstrapMethodArgumentCount];
        for (int i = 0; i < bootstrapMethodArgumentCount; ++i) {
            remappedBootstrapMethodArguments[i] = mapValue(constantDynamic.getBootstrapMethodArgument(i));
        }
        String descriptor = constantDynamic.getDescriptor();
        return new ConstantDynamic(mapInvokeDynamicMethodName(constantDynamic.getName(), descriptor), mapDesc(descriptor), (Handle) mapValue(constantDynamic.getBootstrapMethod()), remappedBootstrapMethodArguments);
    }
    return value;
}
Also used : Type(org.apache.tapestry5.internal.plastic.asm.Type) Handle(org.apache.tapestry5.internal.plastic.asm.Handle) ConstantDynamic(org.apache.tapestry5.internal.plastic.asm.ConstantDynamic)

Example 4 with Handle

use of org.apache.tapestry5.internal.plastic.asm.Handle in project tapestry-5 by apache.

the class ComponentEventRequestHandlerImpl method handle.

public void handle(ComponentEventRequestParameters parameters) throws IOException {
    Page activePage = cache.get(parameters.getActivePageName());
    if (pageActivator.activatePage(activePage.getRootElement().getComponentResources(), parameters.getPageActivationContext(), resultProcessor)) {
        return;
    }
    Page containerPage = cache.get(parameters.getContainingPageName());
    TrackableComponentEventCallback callback = new ComponentResultProcessorWrapper(resultProcessor);
    environment.push(ComponentEventResultProcessor.class, resultProcessor);
    environment.push(TrackableComponentEventCallback.class, callback);
    ComponentPageElement element = containerPage.getComponentElementByNestedId(parameters.getNestedComponentId());
    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);
    if (callback.isAborted()) {
        callback.rethrow();
        return;
    }
    if (!response.isCommitted()) {
        resultProcessor.processResultValue(activePage.getName());
    }
}
Also used : ComponentPageElement(org.apache.tapestry5.internal.structure.ComponentPageElement) TrackableComponentEventCallback(org.apache.tapestry5.TrackableComponentEventCallback) Page(org.apache.tapestry5.internal.structure.Page) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Example 5 with Handle

use of org.apache.tapestry5.internal.plastic.asm.Handle in project tapestry-5 by apache.

the class AppModule method setupCustomBaseURLSource.

@Contribute(ServiceOverride.class)
public void setupCustomBaseURLSource(MappedConfiguration<Class, Object> configuration) {
    BaseURLSource source = new BaseURLSource() {

        public String getBaseURL(boolean secure) {
            String protocol = secure ? "https" : "http";
            // This is all a bit jury-rigged together. This is for running the app
            // interactively; Selenium doesn't seem to handle the transition to https.
            int port = secure ? 8443 : 9090;
            return String.format("%s://localhost:%d", protocol, port);
        }
    };
    configuration.add(BaseURLSource.class, source);
}
Also used : BaseURLSource(org.apache.tapestry5.http.services.BaseURLSource) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Aggregations

Component (org.apache.tapestry5.runtime.Component)5 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)4 ComponentEvent (org.apache.tapestry5.runtime.ComponentEvent)4 ComponentEventHandler (org.apache.tapestry5.services.ComponentEventHandler)4 TrackableComponentEventCallback (org.apache.tapestry5.TrackableComponentEventCallback)3 ConstantDynamic (org.apache.tapestry5.internal.plastic.asm.ConstantDynamic)3 Handle (org.apache.tapestry5.internal.plastic.asm.Handle)3 Type (org.apache.tapestry5.internal.plastic.asm.Type)3 Page (org.apache.tapestry5.internal.structure.Page)3 FieldHandle (org.apache.tapestry5.plastic.FieldHandle)3 ComponentEventRequestHandler (org.apache.tapestry5.services.ComponentEventRequestHandler)3 IOException (java.io.IOException)2 Link (org.apache.tapestry5.http.Link)2 ComponentPageElement (org.apache.tapestry5.internal.structure.ComponentPageElement)2 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)2 JSONObject (org.apache.tapestry5.json.JSONObject)2 ComponentEventRequestFilter (org.apache.tapestry5.services.ComponentEventRequestFilter)2 PageRenderRequestFilter (org.apache.tapestry5.services.PageRenderRequestFilter)2 PageRenderRequestHandler (org.apache.tapestry5.services.PageRenderRequestHandler)2 Test (org.testng.annotations.Test)2