Search in sources :

Example 6 with Environment

use of com.github.bordertech.wcomponents.Environment in project wcomponents by BorderTech.

the class InfoDump method dumpWEnvironment.

/**
 * Appends the current environment to the console.
 */
private void dumpWEnvironment() {
    StringBuffer text = new StringBuffer();
    Environment env = getEnvironment();
    text.append("\n\nWEnvironment" + "\n------------");
    text.append("\nAppId: ").append(env.getAppId());
    text.append("\nBaseUrl: ").append(env.getBaseUrl());
    text.append("\nHostFreeBaseUrl: ").append(env.getHostFreeBaseUrl());
    text.append("\nPostPath: ").append(env.getPostPath());
    text.append("\nTargetablePath: ").append(env.getWServletPath());
    text.append("\nAppHostPath: ").append(env.getAppHostPath());
    text.append("\nThemePath: ").append(env.getThemePath());
    text.append("\nStep: ").append(env.getStep());
    text.append("\nSession Token: ").append(env.getSessionToken());
    text.append("\nFormEncType: ").append(env.getFormEncType());
    text.append('\n');
    appendToConsole(text.toString());
}
Also used : Environment(com.github.bordertech.wcomponents.Environment)

Example 7 with Environment

use of com.github.bordertech.wcomponents.Environment in project wcomponents by BorderTech.

the class WWindowInterceptor method serviceRequest.

/**
 * Temporarily replaces the environment while the request is being handled.
 *
 * @param request the request being responded to.
 */
@Override
public void serviceRequest(final Request request) {
    // Get window id off the request
    windowId = request.getParameter(WWindow.WWINDOW_REQUEST_PARAM_KEY);
    if (windowId == null) {
        super.serviceRequest(request);
    } else {
        // Get the window component
        ComponentWithContext target = WebUtilities.getComponentById(windowId, true);
        if (target == null) {
            throw new SystemException("No window component for id " + windowId);
        }
        // Setup the Environment on the context
        UIContext uic = UIContextHolder.getCurrentPrimaryUIContext();
        Environment originalEnvironment = uic.getEnvironment();
        uic.setEnvironment(new EnvironmentDelegate(originalEnvironment, windowId, target));
        if (attachWindow) {
            attachUI(target.getComponent());
        }
        UIContextHolder.pushContext(target.getContext());
        try {
            super.serviceRequest(request);
        } finally {
            uic.setEnvironment(originalEnvironment);
            UIContextHolder.popContext();
        }
    }
}
Also used : SystemException(com.github.bordertech.wcomponents.util.SystemException) UIContext(com.github.bordertech.wcomponents.UIContext) Environment(com.github.bordertech.wcomponents.Environment) ComponentWithContext(com.github.bordertech.wcomponents.ComponentWithContext)

Aggregations

Environment (com.github.bordertech.wcomponents.Environment)7 UIContext (com.github.bordertech.wcomponents.UIContext)6 SystemException (com.github.bordertech.wcomponents.util.SystemException)4 ComponentWithContext (com.github.bordertech.wcomponents.ComponentWithContext)3 ActionEscape (com.github.bordertech.wcomponents.ActionEscape)1 Escape (com.github.bordertech.wcomponents.Escape)1 Response (com.github.bordertech.wcomponents.Response)1 WApplication (com.github.bordertech.wcomponents.WApplication)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)1 SeleniumWComponentsWebDriver (com.github.bordertech.wcomponents.test.selenium.driver.SeleniumWComponentsWebDriver)1 PrintWriter (java.io.PrintWriter)1 Test (org.junit.Test)1