Search in sources :

Example 11 with WOActionResults

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

the class AjaxSubmitButton method handleRequest.

@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
    WOComponent component = context.component();
    WOActionResults result = (WOActionResults) valueForBinding("action", component);
    if (ERXAjaxApplication.isAjaxReplacement(request)) {
        AjaxUtils.setPageReplacementCacheKey(context, (String) valueForBinding("replaceID", component));
    } else if (result == null || booleanValueForBinding("ignoreActionResponse", false, component)) {
        WOResponse response = AjaxUtils.createResponse(request, context);
        String onClickServer = (String) valueForBinding("onClickServer", component);
        if (onClickServer != null) {
            AjaxUtils.appendScriptHeaderIfNecessary(request, response);
            response.appendContentString(onClickServer);
            AjaxUtils.appendScriptFooterIfNecessary(request, response);
        }
        result = response;
    } else {
        String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
        if (updateContainerID != null) {
            AjaxUtils.setPageReplacementCacheKey(context, updateContainerID);
        }
    }
    return result;
}
Also used : WOActionResults(com.webobjects.appserver.WOActionResults) WOComponent(com.webobjects.appserver.WOComponent) WOResponse(com.webobjects.appserver.WOResponse)

Example 12 with WOActionResults

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

the class ERXAjaxApplication method invokeAction.

/**
 * Overridden to allow for redirected responses.
 */
@Override
public WOActionResults invokeAction(WORequest request, WOContext context) {
    WOActionResults results = super.invokeAction(request, context);
    // wrong
    if (ERXAjaxApplication.shouldNotStorePage(context)) {
        if (shouldIgnoreResults(request, context, results)) {
            results = null;
        }
        if (results == null && !ERXAjaxApplication.isAjaxReplacement(request)) {
            WOResponse response = context.response();
            if (_responseDelegate != null) {
                results = _responseDelegate.handleNullActionResults(request, response, context);
                response = context.response();
            }
            // MS: We were removing headers, and I really don't know WHY.  It was causing AUC's
            // inside of AjaxModalDialogs to break ... ERXAjaxSession is already cleaning up
            // headers at the end, so this seems very odd to me.  If you remove headers here,
            // it causes ERXAjaxSession to not treat the response like an Ajax response.
            // ERXAjaxApplication.cleanUpHeaders(response);
            results = response;
        }
    }
    return results;
}
Also used : WOActionResults(com.webobjects.appserver.WOActionResults) WOResponse(com.webobjects.appserver.WOResponse)

Example 13 with WOActionResults

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

the class ERXWOForm method invokeAction.

@Override
public WOActionResults invokeAction(WORequest worequest, WOContext context) {
    boolean wasInForm = context.isInForm();
    WOActionResults result;
    if (_shouldAppendFormTags(context, wasInForm)) {
        boolean wasFormSubmitted = context.wasFormSubmitted();
        _enterFormInContext(context);
        boolean wasMultipleSubmitForm = context.isMultipleSubmitForm();
        String enctype = _enctype(context);
        if (enctype != null) {
            _setEnctype(enctype);
        }
        context.setActionInvoked(false);
        context.setIsMultipleSubmitForm(_multipleSubmit == null ? false : _multipleSubmit.booleanValueInComponent(context.component()));
        String previousFormName = _setFormName(context, wasInForm);
        try {
            result = super.invokeAction(worequest, context);
            if (!wasInForm && !context.wasActionInvoked() && context.wasFormSubmitted()) {
                if (_action != null) {
                    result = (WOActionResults) _action.valueInComponent(context.component());
                }
                if (result == null && !ERXAjaxApplication.isAjaxSubmit(worequest)) {
                    result = context.page();
                }
            }
        } finally {
            context.setIsMultipleSubmitForm(wasMultipleSubmitForm);
            _exitFormInContext(context, wasInForm, wasFormSubmitted);
            _clearFormName(context, previousFormName, wasInForm);
            _clearEnctype();
        }
    } else {
        result = super.invokeAction(worequest, context);
    }
    return result;
}
Also used : WOActionResults(com.webobjects.appserver.WOActionResults)

Example 14 with WOActionResults

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

the class ERXWOHyperlink method invokeAction.

/**
 * Overridden to perform the logging, propagating the action to subelements and returning the
 * current page if an empty page is returned from super.
 */
@Override
public WOActionResults invokeAction(WORequest request, WOContext context) {
    WOActionResults result = super.invokeAction(request, context);
    if (result != null && (result instanceof WONoContentElement)) {
        result = context.page();
    }
    if (result == null) {
        String sender = context.senderID();
        String element = context.elementID();
        if (sender.startsWith(element) && !element.equals(sender)) {
            result = invokeChildrenAction(request, context);
        }
    }
    if (result != null && ERXSession.anySession() != null) {
        ERXSession.anySession().setObjectForKey(toString(), "ERXActionLogging");
    }
    return result;
}
Also used : WOActionResults(com.webobjects.appserver.WOActionResults) WONoContentElement(com.webobjects.appserver._private.WONoContentElement)

Example 15 with WOActionResults

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

the class ERXWORepetition method invokeAction.

@Override
public WOActionResults invokeAction(WORequest worequest, WOContext wocontext) {
    WOComponent wocomponent = wocontext.component();
    Context repetitionContext = createContext(wocomponent);
    int count = _count(repetitionContext, wocomponent);
    WOActionResults woactionresults = null;
    String indexString = _indexOfChosenItem(worequest, wocontext);
    int index = 0;
    boolean checkHashCodes = checkHashCodes(wocomponent);
    if (indexString != null && !checkHashCodes) {
        index = Integer.parseInt(indexString);
    }
    if (indexString != null) {
        if (_item != null) {
            Object object = null;
            if (checkHashCodes) {
                boolean found = false;
                if (_uniqueKey == null) {
                    int hashCode = Integer.parseInt(indexString);
                    int otherHashCode = 0;
                    for (int i = 0; i < repetitionContext.count() && !found; i++) {
                        Object o = repetitionContext.objectAtIndex(i);
                        otherHashCode = hashCodeForObject(wocomponent, o);
                        if (otherHashCode == hashCode) {
                            object = o;
                            index = i;
                            found = true;
                        }
                    }
                    if (found) {
                        log.debug("Found object: {} vs {}", otherHashCode, hashCode);
                    } else {
                        log.warn("Wrong object: {} vs {} (array = {})", otherHashCode, hashCode, repetitionContext.nsarray);
                    }
                } else {
                    String key = indexString;
                    String otherKey = null;
                    for (int i = 0; i < repetitionContext.count() && !found; i++) {
                        Object o = repetitionContext.objectAtIndex(i);
                        otherKey = keyForObject(wocomponent, o);
                        if (otherKey.equals(key)) {
                            object = o;
                            index = i;
                            found = true;
                        }
                    }
                    if (found) {
                        log.debug("Found object: {} vs {}", otherKey, key);
                    } else {
                        log.warn("Wrong object: {} vs {} (array = {})", otherKey, key, repetitionContext.nsarray);
                    }
                }
                if (!found) {
                    if (raiseOnUnmatchedObject(wocomponent)) {
                        throw new UnmatchedObjectException();
                    }
                    if (_notFoundMarker == null) {
                        return wocontext.page();
                    }
                    object = _notFoundMarker.valueInComponent(wocomponent);
                }
            } else {
                if (index >= repetitionContext.count()) {
                    if (raiseOnUnmatchedObject(wocomponent)) {
                        throw new UnmatchedObjectException();
                    }
                    return wocontext.page();
                }
                object = repetitionContext.objectAtIndex(index);
            }
            _item._setValueNoValidation(object, wocomponent);
        }
        if (_index != null) {
            _index._setValueNoValidation(index, wocomponent);
        }
        wocontext.appendElementIDComponent(indexString);
        log.debug("invokeAction: {}", wocontext.elementID());
        woactionresults = super.invokeAction(worequest, wocontext);
        wocontext.deleteLastElementIDComponent();
    } else {
        for (int i = 0; i < count && woactionresults == null; i++) {
            _prepareForIterationWithIndex(repetitionContext, i, wocontext, wocomponent, checkHashCodes);
            woactionresults = super.invokeAction(worequest, wocontext);
        }
        if (count > 0) {
            _cleanupAfterIteration(count, wocontext, wocomponent);
        }
    }
    return woactionresults;
}
Also used : WOContext(com.webobjects.appserver.WOContext) ERXWOContext(er.extensions.appserver.ERXWOContext) WOActionResults(com.webobjects.appserver.WOActionResults) WOComponent(com.webobjects.appserver.WOComponent)

Aggregations

WOActionResults (com.webobjects.appserver.WOActionResults)31 WOComponent (com.webobjects.appserver.WOComponent)11 WOResponse (com.webobjects.appserver.WOResponse)6 WOElement (com.webobjects.appserver.WOElement)2 WOApplication (com.webobjects.appserver.WOApplication)1 WOContext (com.webobjects.appserver.WOContext)1 WORequest (com.webobjects.appserver.WORequest)1 WOForm (com.webobjects.appserver._private.WOForm)1 WONoContentElement (com.webobjects.appserver._private.WONoContentElement)1 NSArray (com.webobjects.foundation.NSArray)1 NSData (com.webobjects.foundation.NSData)1 NSMutableArray (com.webobjects.foundation.NSMutableArray)1 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)1 NSRange (com.webobjects.foundation.NSRange)1 ERXWOContext (er.extensions.appserver.ERXWOContext)1 ERXWOForm (er.extensions.components._private.ERXWOForm)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1