use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.
the class AjaxUpdateLink method handleRequest.
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
WOComponent component = context.component();
boolean disabled = booleanValueForBinding("disabled", false, component);
String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
AjaxUpdateContainer.setUpdateContainerID(request, updateContainerID);
WOActionResults results = null;
if (!disabled) {
results = (WOActionResults) valueForBinding("action", component);
}
if (ERXAjaxApplication.isAjaxReplacement(request)) {
AjaxUtils.setPageReplacementCacheKey(context, (String) valueForBinding("replaceID", component));
} else if (results == null || booleanValueForBinding("ignoreActionResponse", false, component)) {
String script = (String) valueForBinding("onClickServer", component);
if (script != null) {
WOResponse response = AjaxUtils.createResponse(request, context);
AjaxUtils.appendScriptHeaderIfNecessary(request, response);
response.appendContentString(script);
AjaxUtils.appendScriptFooterIfNecessary(request, response);
results = response;
}
} else if (updateContainerID != null) {
AjaxUtils.setPageReplacementCacheKey(context, updateContainerID);
}
return results;
}
use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.
the class AjaxProxy method handleRequest.
/**
* Ask the an JSONRPCBridge object to handle the json request.
*/
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
WOResponse response = AjaxUtils.createResponse(request, context);
response.setHeader("application/json", "content-type");
String inputString = request.contentString();
log.debug("AjaxProxy.handleRequest: input = {}", inputString);
// Process the request
JSONObject input = null;
Object output = null;
try {
input = new JSONObject(inputString);
Object proxy;
if (canGetValueForBinding("proxy")) {
proxy = valueForBinding("proxy");
} else {
proxy = parent();
log.warn("No proxy binding given, so using parent component. This is probably a very bad idea.");
}
String proxyName = (String) valueForBinding("proxyName");
JSONRPCBridge bridge = getBridgeBinding();
if (bridge == null) {
bridge = JSONBridge.createBridge();
setBridgeBinding(bridge);
}
bridge.registerObject(proxyName, proxy);
output = bridge.call(new Object[] { request, context, response, proxy }, input);
} catch (NoSuchElementException e) {
log.error("No method in request");
output = JSONRPCResult.MSG_ERR_NOMETHOD;
} catch (Exception e) {
log.error("Exception", e);
output = JSONRPCResult.MSG_ERR_NOMETHOD;
}
// Write the response
log.debug("AjaxProxy.handleRequest: output = {}", output);
response.appendContentString(output.toString());
return response;
}
use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.
the class AjaxRequestHandler method handleRequest.
@Override
public WOResponse handleRequest(WORequest request) {
ERXAjaxApplication.enableShouldNotStorePage();
WOResponse response = super.handleRequest(request);
return response;
}
use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.
the class AjaxAutoComplete method handleRequest.
/**
* Handles the Ajax request. Checks for the form value in the edit field,
* pushes it up to the parent and pulls the "list" binding. The parent is
* responsible for returning a list with some items that match the current value.
*/
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
// String inputString = request.contentString();
String fieldValue = context.request().stringFormValueForKey(fieldName);
setValueForBinding(fieldValue, "value");
WOResponse response = AjaxUtils.createResponse(request, context);
response.appendContentString("<ul>");
int maxItems = maxItems();
int itemsCount = 0;
Object values = valueForBinding("list");
WOElement child = _childTemplate();
boolean hasItem = hasBinding("item");
if (values instanceof NSArray) {
for (Enumeration valueEnum = ((NSArray) values).objectEnumerator(); valueEnum.hasMoreElements() && itemsCount++ < maxItems; ) {
appendItemToResponse(valueEnum.nextElement(), child, hasItem, response, context);
}
} else if (values instanceof List) {
for (Iterator iter = ((List) values).iterator(); iter.hasNext() && itemsCount++ < maxItems; ) {
appendItemToResponse(iter.next(), child, hasItem, response, context);
}
} else if (values instanceof Object[]) {
Object[] array = (Object[]) values;
for (int i = 0; i < array.length && i < maxItems; i++) {
appendItemToResponse(array[i], child, hasItem, response, context);
}
} else if (values != null) {
log.warn("Unsupported class type for list: {}", values.getClass().getCanonicalName());
}
response.appendContentString("</ul>");
return response;
}
use of com.webobjects.appserver.WOResponse in project wonder-slim by undur.
the class ERXDirectActionRequestHandler method handleRequest.
@Override
public WOResponse handleRequest(WORequest request) {
WOResponse response = null;
// ak: when addressed with a DA link with this instance's ID (and
// an expired session) and the app is refusing new sessions, the
// default implementation will create a session anyway, which will
// wreak havoc if the app is memory starved.
// Search engines are a nuisance in that regard
WOApplication app = WOApplication.application();
if (app.isRefusingNewSessions() && request.isUsingWebServer() && !isSystemRequest(request)) {
if (isSessionIDInRequest(request)) {
// yadda-yadda.
if (app.sessionStore().getClass() == WOServerSessionStore.class) {
if (app.sessionStore().restoreSessionWithID(request.sessionID(), request) == null) {
response = generateRequestRefusal(request);
// AK: should be a permanent redirect, as the session is gone for good.
// However, the adaptor checks explicitly on 302 so we return that...
// It shouldn't matter which instance we go to now.
response.setStatus(302);
}
}
} else {
// if no session was supplied, what are we doing here in the
// first place? The adaptor shouldn't have linked to us as
// we are refusing new sessions.
response = generateRequestRefusal(request);
}
}
if (response == null) {
response = super.handleRequest(request);
}
return response;
}
Aggregations