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("//-->");
}
}
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);
}
}
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);
}
}
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;
}
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;
}
Aggregations