Java Code Examples for com.vaadin.server.VaadinRequest#getWrappedSession()

The following examples show how to use com.vaadin.server.VaadinRequest#getWrappedSession() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppUI.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void processLinkHandlerRequest(VaadinRequest request) {
    WrappedSession wrappedSession = request.getWrappedSession();
    //noinspection unchecked
    Map<String, String> params =
            (Map<String, String>) wrappedSession.getAttribute(LAST_REQUEST_PARAMS_ATTR);
    params = params != null ? params : Collections.emptyMap();

    try {
        String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);
        LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, app, action, params);
        if (app.connection.isConnected() && linkHandler.canHandleLink()) {
            linkHandler.handle();
        } else {
            app.linkHandler = linkHandler;
        }
    } catch (Exception e) {
        error(new com.vaadin.server.ErrorEvent(e));
    }
}
 
Example 2
Source File: LinkHandler.java    From cuba with Apache License 2.0 6 votes vote down vote up
/**
 * Called to handle the link.
 */
public void handle() {
    try {
        ExternalLinkContext linkContext = new ExternalLinkContext(requestParams, action, app);
        for (LinkHandlerProcessor processor : processors) {
            if (processor.canHandle(linkContext)) {
                processor.handle(linkContext);
                break;
            }
        }
    } finally {
        VaadinRequest request = VaadinService.getCurrentRequest();
        WrappedSession wrappedSession = request.getWrappedSession();
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_PARAMS_ATTR);
        wrappedSession.removeAttribute(AppUI.LAST_REQUEST_ACTION_ATTR);
    }
}
 
Example 3
Source File: AppUI.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected boolean isLinkHandlerRequest(VaadinRequest request) {
    WrappedSession wrappedSession = request.getWrappedSession();
    if (wrappedSession == null) {
        return false;
    }

    String action = (String) wrappedSession.getAttribute(LAST_REQUEST_ACTION_ATTR);

    return webConfig.getLinkHandlerActions().contains(action);
}