Search in sources :

Example 31 with WOResponse

use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.

the class ERXComponentRequestHandler method handleRequest.

@Override
public WOResponse handleRequest(WORequest aRequest) {
    WOApplication anApplication = WOApplication.application();
    Object globalLock = anApplication.requestHandlingLock();
    WOResponse aResponse;
    if (globalLock != null) {
        synchronized (globalLock) {
            aResponse = _handleRequest(aRequest);
        }
    } else {
        aResponse = _handleRequest(aRequest);
    }
    return aResponse;
}
Also used : WOResponse(com.webobjects.appserver.WOResponse) WOApplication(com.webobjects.appserver.WOApplication)

Example 32 with WOResponse

use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.

the class ERXComponentRequestHandler method _dispatchWithPreparedPage.

private WOResponse _dispatchWithPreparedPage(WOComponent aPage, WOSession aSession, WOContext aContext, NSDictionary someElements) {
    WORequest aRequest = aContext.request();
    WOApplication anApplication = WOApplication.application();
    WOResponse aResponse = anApplication.createResponseInContext(aContext);
    String aSenderID = aContext.senderID();
    String oldContextID = aSession._contextIDMatchingIDs(aContext);
    aResponse.setHTTPVersion(aRequest.httpVersion());
    aResponse.setHeader("text/html", "content-type");
    aContext._setResponse(aResponse);
    if (oldContextID == null) {
        if (aSenderID != null) {
            if (aRequest._hasFormValues()) {
                anApplication.takeValuesFromRequest(aRequest, aContext);
            }
        }
        aContext._setPageChanged(false);
        if (aSenderID != null) {
            WOActionResults anActionResults = anApplication.invokeAction(aRequest, aContext);
            if ((anActionResults == null) || ((anActionResults instanceof WOComponent))) {
                WOComponent aResultComponent = (WOComponent) anActionResults;
                if ((aResultComponent != null) && (aResultComponent.context() != aContext)) {
                    aResultComponent._awakeInContext(aContext);
                }
                boolean didPageChange = false;
                if ((aResultComponent != null) && (aResultComponent != aContext._pageElement())) {
                    didPageChange = true;
                }
                aContext._setPageChanged(didPageChange);
                if (didPageChange) {
                    aContext._setPageElement(aResultComponent);
                }
            } else {
                WOResponse theResponse = anActionResults.generateResponse();
                return theResponse;
            }
        }
    } else {
        WOComponent responsePage = _restorePageForContextID(oldContextID, aSession);
        aContext._setPageElement(responsePage);
    }
    anApplication.appendToResponse(aResponse, aContext);
    return aResponse;
}
Also used : WORequest(com.webobjects.appserver.WORequest) WOActionResults(com.webobjects.appserver.WOActionResults) WOComponent(com.webobjects.appserver.WOComponent) WOResponse(com.webobjects.appserver.WOResponse) WOApplication(com.webobjects.appserver.WOApplication)

Example 33 with WOResponse

use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.

the class ERXJavaScript method appendAttributesToResponse.

@Override
public void appendAttributesToResponse(WOResponse woresponse, WOContext wocontext) {
    WOComponent wocomponent = wocontext.component();
    woresponse._appendContentAsciiString(" type=\"text/javascript\"");
    String framework = null;
    String scriptName = null;
    String src = null;
    if (_scriptSource != null || _filename != null) {
        String srcFromBindings;
        if (_scriptSource != null) {
            srcFromBindings = (String) _scriptSource.valueInComponent(wocomponent);
        } else {
            srcFromBindings = (String) _filename.valueInComponent(wocomponent);
        }
        if (srcFromBindings != null) {
            if (!WOStaticURLUtilities.isRelativeURL(srcFromBindings)) {
                src = srcFromBindings;
            } else {
                if (!WOStaticURLUtilities.isFragmentURL(srcFromBindings)) {
                    if (_scriptFramework != null) {
                        framework = (String) _scriptFramework.valueInComponent(wocomponent);
                    } else if (_framework != null) {
                        framework = (String) _framework.valueInComponent(wocomponent);
                    }
                    scriptName = srcFromBindings;
                    src = wocontext._urlForResourceNamed(srcFromBindings, framework, true);
                    if (src == null) {
                        src = wocomponent.baseURL() + "/" + srcFromBindings;
                    } else if (ERXResourceManager._shouldGenerateCompleteResourceURL(wocontext)) {
                        src = ERXResourceManager._completeURLForResource(src, null, wocontext);
                    }
                } else {
                    log.warn("relative fragment URL {}", srcFromBindings);
                }
            }
        }
    }
    Object key = null;
    if (src == null && _scriptKey != null) {
        key = _scriptKey.valueInComponent(wocomponent);
        if (key != null) {
            ERXExpiringCache<Object, WOResponse> cache = ERXJavaScript.cache(wocontext.session());
            boolean render = cache.isStale(key);
            render |= ERXApplication.isDevelopmentModeSafe();
            if (render) {
                WOResponse newresponse = new WOResponse();
                super.appendChildrenToResponse(newresponse, wocontext);
                newresponse.setHeader("application/x-javascript", "content-type");
                cache.setObjectForKey(newresponse, key);
            }
            src = wocontext.directActionURLForActionNamed(Script.class.getName() + "/" + key, null);
        }
    }
    if (src != null) {
        woresponse._appendContentAsciiString(" src=\"");
        woresponse.appendContentString(src);
        woresponse.appendContentCharacter('"');
    }
    super.appendAttributesToResponse(woresponse, wocontext);
    if (scriptName != null) {
        ERXResponseRewriter.resourceAddedToHead(wocontext, framework, scriptName);
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WOResponse(com.webobjects.appserver.WOResponse)

Aggregations

WOResponse (com.webobjects.appserver.WOResponse)33 WOComponent (com.webobjects.appserver.WOComponent)10 WOApplication (com.webobjects.appserver.WOApplication)7 WOActionResults (com.webobjects.appserver.WOActionResults)6 WOContext (com.webobjects.appserver.WOContext)5 WORequest (com.webobjects.appserver.WORequest)4 WOSession (com.webobjects.appserver.WOSession)4 NSDictionary (com.webobjects.foundation.NSDictionary)4 WODynamicURL (com.webobjects.appserver.WODynamicURL)2 NSArray (com.webobjects.foundation.NSArray)2 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 NoSuchElementException (java.util.NoSuchElementException)2 JSONRPCBridge (org.jabsorb.JSONRPCBridge)2 JSONObject (org.json.JSONObject)2 WOAssociation (com.webobjects.appserver.WOAssociation)1