Search in sources :

Example 31 with WOComponent

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

the class ERXJavaScript method appendChildrenToResponse.

@Override
public void appendChildrenToResponse(WOResponse woresponse, WOContext wocontext) {
    String script = "";
    boolean hideInComment = ERXProperties.booleanForKeyWithDefault("er.extensions.ERXJavaScript.hideInComment", true);
    WOComponent wocomponent = wocontext.component();
    if (_hideInComment != null) {
        hideInComment = _hideInComment.booleanValueInComponent(wocomponent);
    }
    if (hideInComment) {
        woresponse._appendContentAsciiString("<!--");
    }
    woresponse.appendContentCharacter('\n');
    if (_scriptFile != null) {
        String filename = (String) _scriptFile.valueInComponent(wocomponent);
        if (filename != null) {
            String framework = null;
            if (_scriptFramework != null) {
                framework = (String) _scriptFramework.valueInComponent(wocomponent);
            } else if (_framework != null) {
                framework = (String) _framework.valueInComponent(wocomponent);
            }
            java.net.URL url = WOApplication.application().resourceManager().pathURLForResourceNamed(filename, framework, wocontext._languages());
            if (url == null) {
                url = wocontext.component()._componentDefinition().pathURLForResourceNamed(filename, framework, wocontext._languages());
            }
            if (url == null) {
                throw new WODynamicElementCreationException("<" + getClass().getName() + "> : cannot find script file '" + filename + "'");
            }
            script = _NSStringUtilities.stringFromPathURL(url);
            if (ERXResourceManager._shouldGenerateCompleteResourceURL(wocontext)) {
                script = ERXResourceManager._completeURLForResource(script, null, wocontext);
            }
        }
        woresponse.appendContentString(script);
    } else if (_scriptString != null) {
        Object obj1 = _scriptString.valueInComponent(wocomponent);
        if (obj1 != null) {
            script = obj1.toString();
        }
        woresponse.appendContentString(script);
    } else {
        super.appendChildrenToResponse(woresponse, wocontext);
    }
    woresponse.appendContentCharacter('\n');
    if (hideInComment) {
        woresponse._appendContentAsciiString("//-->");
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WODynamicElementCreationException(com.webobjects.appserver._private.WODynamicElementCreationException)

Example 32 with WOComponent

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

the class ERXWOComponentContent method appendToResponse.

@Override
public void appendToResponse(WOResponse woresponse, WOContext wocontext) {
    WOComponent component = wocontext.component();
    WOElement template = template(component);
    if (template != null) {
        wocontext._setCurrentComponent(component.parent());
        template.appendToResponse(woresponse, wocontext);
        wocontext._setCurrentComponent(component);
    } else {
        _defaultTemplate.appendToResponse(woresponse, wocontext);
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WOElement(com.webobjects.appserver.WOElement)

Example 33 with WOComponent

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

the class ERXWOComponentContent method takeValuesFromRequest.

@Override
public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) {
    WOComponent component = wocontext.component();
    WOElement template = template(component);
    if (template != null) {
        wocontext._setCurrentComponent(component.parent());
        template.takeValuesFromRequest(worequest, wocontext);
        wocontext._setCurrentComponent(component);
    } else {
        _defaultTemplate.takeValuesFromRequest(worequest, wocontext);
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WOElement(com.webobjects.appserver.WOElement)

Example 34 with WOComponent

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

the class ERXComponentRequestHandler method _dispatchWithPreparedSession.

private WOResponse _dispatchWithPreparedSession(WOSession aSession, WOContext aContext, NSDictionary someElements) {
    WOComponent aPage = null;
    WOResponse aResponse = null;
    String aPageName = (String) someElements.objectForKey("wopage");
    String oldContextID = aContext._requestContextID();
    String oldSessionID = (String) someElements.objectForKey(WOApplication.application().sessionIdKey());
    WOApplication anApplication = WOApplication.application();
    boolean clearIDsInCookies = false;
    if ((oldSessionID == null) || (oldContextID == null)) {
        if ((aPageName == null) && (!aSession.storesIDsInCookies())) {
            WORequest request = aContext.request();
            String cookieHeader = request.headerForKey("cookie");
            if ((cookieHeader != null) && (cookieHeader.length() > 0)) {
                NSDictionary cookieDict = request.cookieValues();
                if ((cookieDict.objectForKey(WOApplication.application().sessionIdKey()) != null) || (cookieDict.objectForKey(WOApplication.application().instanceIdKey()) != null)) {
                    clearIDsInCookies = true;
                }
            }
        }
        aPage = anApplication.pageWithName(aPageName, aContext);
    } else {
        aPage = _restorePageForContextID(oldContextID, aSession);
        if (aPage == null) {
            if (anApplication._isPageRecreationEnabled())
                aPage = anApplication.pageWithName(aPageName, aContext);
            else {
                return anApplication.handlePageRestorationErrorInContext(aContext);
            }
        }
    }
    aContext._setPageElement(aPage);
    aResponse = _dispatchWithPreparedPage(aPage, aSession, aContext, someElements);
    if (anApplication.isPageRefreshOnBacktrackEnabled()) {
        aResponse.disableClientCaching();
    }
    aSession._saveCurrentPage();
    if ((clearIDsInCookies) && (!aSession.storesIDsInCookies())) {
        aSession._clearCookieFromResponse(aResponse);
    }
    return aResponse;
}
Also used : WORequest(com.webobjects.appserver.WORequest) WOComponent(com.webobjects.appserver.WOComponent) NSDictionary(com.webobjects.foundation.NSDictionary) WOResponse(com.webobjects.appserver.WOResponse) WOApplication(com.webobjects.appserver.WOApplication)

Example 35 with WOComponent

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

the class ERXComponentRequestHandler method _handleRequest.

WOResponse _handleRequest(WORequest aRequest) {
    WOContext aContext = null;
    WOResponse aResponse;
    NSDictionary requestHandlerValues = requestHandlerValuesForRequest(aRequest);
    WOApplication anApplication = WOApplication.application();
    String aSessionID = (String) requestHandlerValues.objectForKey(WOApplication.application().sessionIdKey());
    if ((!anApplication.isRefusingNewSessions()) || (aSessionID != null)) {
        String aSenderID = (String) requestHandlerValues.objectForKey("woeid");
        String oldContextID = (String) requestHandlerValues.objectForKey("wocid");
        WOStatisticsStore aStatisticsStore = anApplication.statisticsStore();
        if (aStatisticsStore != null)
            aStatisticsStore.applicationWillHandleComponentActionRequest();
        try {
            aContext = anApplication.createContextForRequest(aRequest);
            aContext._setRequestContextID(oldContextID);
            aContext._setSenderID(aSenderID);
            anApplication.awake();
            aResponse = _dispatchWithPreparedApplication(anApplication, aContext, requestHandlerValues);
            NSNotificationCenter.defaultCenter().postNotification(WORequestHandler.DidHandleRequestNotification, aContext);
            anApplication.sleep();
        } catch (Exception exception) {
            try {
                NSLog.err.appendln("<" + getClass().getName() + ">: Exception occurred while handling request:\n" + exception.toString());
                if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 4L)) {
                    NSLog.debug.appendln(exception);
                }
                if (aContext == null)
                    aContext = anApplication.createContextForRequest(aRequest);
                else {
                    aContext._putAwakeComponentsToSleep();
                }
                WOSession aSession = aContext._session();
                aResponse = anApplication.handleException(exception, aContext);
                if (aSession != null) {
                    try {
                        anApplication.saveSessionForContext(aContext);
                        anApplication.sleep();
                    } catch (Exception eAgain) {
                        NSLog.err.appendln("<WOApplication '" + anApplication.name() + "'>: Another Exception  occurred while trying to clean the application:\n" + eAgain.toString());
                        if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 4L))
                            NSLog.debug.appendln(eAgain);
                    }
                }
            } finally {
                if ((aContext != null) && (aContext._session() != null))
                    anApplication.saveSessionForContext(aContext);
            }
        }
        if (aResponse != null) {
            aResponse._finalizeInContext(aContext);
        }
        if (aStatisticsStore != null) {
            WOComponent aPage = aContext.page();
            String aName = null;
            if (aPage != null) {
                aName = aPage.name();
            }
            aStatisticsStore.applicationDidHandleComponentActionRequestWithPageNamed(aName);
        }
    } else {
        String newLocationURL = anApplication._newLocationForRequest(aRequest);
        String contentString = "Sorry, your request could not immediately be processed. Please try this URL: <a href=\"" + newLocationURL + "\">" + newLocationURL + "</a>";
        aResponse = anApplication.createResponseInContext(null);
        WOResponse._redirectResponse(aResponse, newLocationURL, contentString);
        aResponse._finalizeInContext(null);
    }
    return aResponse;
}
Also used : NSDictionary(com.webobjects.foundation.NSDictionary) WOComponent(com.webobjects.appserver.WOComponent) WOContext(com.webobjects.appserver.WOContext) WOSession(com.webobjects.appserver.WOSession) WOStatisticsStore(com.webobjects.appserver.WOStatisticsStore) WOResponse(com.webobjects.appserver.WOResponse) WOApplication(com.webobjects.appserver.WOApplication)

Aggregations

WOComponent (com.webobjects.appserver.WOComponent)68 WOActionResults (com.webobjects.appserver.WOActionResults)11 WOResponse (com.webobjects.appserver.WOResponse)10 WOContext (com.webobjects.appserver.WOContext)8 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)8 NSDictionary (com.webobjects.foundation.NSDictionary)7 Format (java.text.Format)5 WOApplication (com.webobjects.appserver.WOApplication)4 WOAssociation (com.webobjects.appserver.WOAssociation)4 NSMutableArray (com.webobjects.foundation.NSMutableArray)4 ERXWOContext (er.extensions.appserver.ERXWOContext)4 ParseException (java.text.ParseException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 WOElement (com.webobjects.appserver.WOElement)3 WORequest (com.webobjects.appserver.WORequest)3 WODynamicElementCreationException (com.webobjects.appserver._private.WODynamicElementCreationException)3 NSArray (com.webobjects.foundation.NSArray)3 WOSession (com.webobjects.appserver.WOSession)2 ERXMutableURL (er.extensions.foundation.ERXMutableURL)2