use of com.webobjects.appserver._private.WOForm in project wonder-slim by undur.
the class AjaxModalDialog method handleRequest.
/**
* Handles the open and close dialog actions.
*
* @see er.ajax.AjaxComponent#handleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
*
* @return null or dialog contents
*/
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
WOActionResults response = null;
String modalBoxAction = NSPathUtilities.pathExtension(context.senderID());
if ("close".equals(modalBoxAction)) {
// This update can't be done in the closeDialog() method as that also gets called from close(WOContext) and
// and Ajax update is not taking place. If the page structure changes, this update will not take place,
// but the correct container ID is on the URL and the update will still happen thanks to the magic in
// AjaxResponse.AjaxResponseDelegate
String closeUpdateContainerID = AjaxUpdateContainer.updateContainerID((String) valueForBinding("closeUpdateContainerID"));
if (closeUpdateContainerID != null) {
AjaxUpdateContainer.setUpdateContainerID(request, closeUpdateContainerID);
}
// This needs to happen AFTER setting up for an update so that AjaxUtils.appendScriptHeaderIfNecessary
// knows if the script header is needed or not. Doing this before and setting up a JS response in
// the onClose callback, resulted in plain text getting injected into the page.
closeDialog();
} else if ("open".equals(modalBoxAction) && !isOpen()) {
openDialog();
// the awake, takeValues, etc. messages can get passed onto it
if (hasBinding("action")) {
_actionResults = (WOComponent) valueForBinding("action");
_actionResults._awakeInContext(context);
} else if (hasBinding("pageName")) {
_actionResults = pageWithName((String) valueForBinding("pageName"));
_actionResults._awakeInContext(context);
}
// wrong and can correct it.
if (_actionResults != null && (_actionResults.template() instanceof WOForm || _actionResults.template() instanceof ERXWOForm)) {
throw new RuntimeException(_actionResults.name() + " is used as contents of AjaxModalDialog, but starts with WOForm tag. " + "Action elements inside the dialog will not function. Add a space at the start or end of " + _actionResults.name() + ".html");
}
}
if (isOpen()) {
response = AjaxUtils.createResponse(request, context);
// Register the id of this component on the page in the request so that when
// it comes time to cache the context, it knows that this area is an Ajax updating area
AjaxUtils.setPageReplacementCacheKey(context, _containerID(context));
if (_actionResults != null) {
pushActionResultsIntoContext(context);
try {
_actionResults.appendToResponse((WOResponse) response, context);
} finally {
popActionResultsFromContext(context);
}
} else {
// This loads the content from the default ERWOTemplate (our component contents that are not
// in the "link" template.
super.appendToResponse((WOResponse) response, context);
}
}
return response;
}
Aggregations