Search in sources :

Example 61 with WOComponent

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

the class ERXWOBrowser method _fastTakeValuesFromRequest.

private void _fastTakeValuesFromRequest(WORequest worequest, WOContext wocontext) {
    WOComponent wocomponent = wocontext.component();
    if (_selections != null && !isDisabledInContext(wocontext) && wocontext.wasFormSubmitted()) {
        String s = nameInContext(wocontext, wocomponent);
        NSArray nsarray = worequest.formValuesForKey(s);
        int i = nsarray != null ? nsarray.count() : 0;
        NSMutableArray nsmutablearray = new NSMutableArray(i);
        List vector = null;
        if (i != 0) {
            NSArray nsarray1 = null;
            List vector1 = null;
            if (_list != null) {
                Object obj = _list.valueInComponent(wocomponent);
                if (obj != null) {
                    if (obj instanceof NSArray) {
                        nsarray1 = (NSArray) obj;
                    } else if (obj instanceof List) {
                        vector1 = (List) obj;
                        nsmutablearray = null;
                        vector = new ArrayList(i);
                    } else {
                        throw new IllegalArgumentException("<" + getClass().getName() + "> Evaluating 'list' binding returned a " + obj.getClass().getName() + " when it should return either a com.webobjects.foundation.NSArray, or a java.lang.Vector .");
                    }
                }
            }
            for (int j = 0; j < i; j++) {
                String s1 = (String) nsarray.objectAtIndex(j);
                int k = Integer.parseInt(s1);
                if (nsarray1 != null) {
                    Object obj2 = nsarray1.objectAtIndex(k);
                    nsmutablearray.addObject(obj2);
                } else {
                    Object obj3 = vector1.get(k);
                    vector.add(obj3);
                }
            }
        }
        Object newValue = (nsmutablearray != null ? nsmutablearray : vector);
        setSelectedValue(newValue, wocomponent);
    }
}
Also used : NSArray(com.webobjects.foundation.NSArray) WOComponent(com.webobjects.appserver.WOComponent) NSMutableArray(com.webobjects.foundation.NSMutableArray) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 62 with WOComponent

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

the class ERXWOBrowser method appendAttributesToResponse.

@Override
public void appendAttributesToResponse(WOResponse woresponse, WOContext wocontext) {
    super.appendAttributesToResponse(woresponse, wocontext);
    Object obj = null;
    WOComponent wocomponent = wocontext.component();
    if (_size != null) {
        obj = _size.valueInComponent(wocomponent);
    }
    if (_size == null || obj == null || Integer.parseInt(obj.toString()) == 1) {
        obj = WOShared.unsignedIntString(5);
    }
    woresponse._appendTagAttributeAndValue("size", obj.toString(), false);
    if (_multiple != null && _multiple.booleanValueInComponent(wocomponent)) {
        woresponse.appendContentCharacter(' ');
        woresponse._appendContentAsciiString("multiple=\"multiple\"");
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 63 with WOComponent

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

the class ERXWOForm method appendAttributesToResponse.

@Override
public void appendAttributesToResponse(WOResponse response, WOContext context) {
    String formName = _formName(context);
    if (formName != null) {
        response._appendTagAttributeAndValue(ERXWOForm.useIdInsteadOfNameTag ? "id" : "name", formName, false);
    }
    String enctype = _enctype(context);
    if (enctype != null) {
        _setEnctype(enctype);
        response._appendTagAttributeAndValue("enctype", enctype, false);
    }
    boolean secure = secureInContext(context);
    Object hrefObject = null;
    WOComponent wocomponent = context.component();
    super.appendAttributesToResponse(response, context);
    boolean generatingCompleteURLs = context.doesGenerateCompleteURLs();
    boolean requestIsSecure = context.secureMode();
    boolean switchToCompleteURLs = secure ^ requestIsSecure;
    if (switchToCompleteURLs && !generatingCompleteURLs) {
        context.generateCompleteURLs();
    }
    try {
        if (_href != null) {
            hrefObject = _href.valueInComponent(wocomponent);
            // even calling it this way, anyway.
            if (secure && hrefObject != null) {
                hrefObject = hrefObject.toString().replaceFirst("http://", "https://");
            }
        } else if (_directActionName != null || _actionClass != null) {
            hrefObject = cgiAction(response, context, secure);
        } else {
            hrefObject = context.componentActionURL(WOApplication.application().componentRequestHandlerKey(), secure);
        }
        if (hrefObject != null) {
            String href = hrefObject.toString();
            Object fragmentIdentifier = (_fragmentIdentifier != null ? _fragmentIdentifier.valueInComponent(context.component()) : null);
            if (fragmentIdentifier != null) {
                href = href + "#" + fragmentIdentifier;
            }
            response._appendTagAttributeAndValue("action", href, false);
        } else {
            log.error("<WOForm> : action attribute evaluates to null");
        }
    } finally {
        if (switchToCompleteURLs && !generatingCompleteURLs) {
            context.generateRelativeURLs();
        }
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 64 with WOComponent

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

the class ERXWORepetition method appendToResponse.

@Override
public void appendToResponse(WOResponse woresponse, WOContext wocontext) {
    WOComponent wocomponent = wocontext.component();
    Context context = createContext(wocomponent);
    int count = _count(context, wocomponent);
    boolean checkHashCodes = checkHashCodes(wocomponent);
    log.debug("appendToResponse: {}", wocontext.elementID());
    for (int index = 0; index < count; index++) {
        _prepareForIterationWithIndex(context, index, wocontext, wocomponent, checkHashCodes);
        appendChildrenToResponse(woresponse, wocontext);
    }
    if (count > 0) {
        _cleanupAfterIteration(count, wocontext, wocomponent);
    }
}
Also used : WOContext(com.webobjects.appserver.WOContext) ERXWOContext(er.extensions.appserver.ERXWOContext) WOComponent(com.webobjects.appserver.WOComponent)

Example 65 with WOComponent

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

the class ERXWORepetition method takeValuesFromRequest.

@Override
public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) {
    WOComponent wocomponent = wocontext.component();
    Context context = createContext(wocomponent);
    int count = _count(context, wocomponent);
    boolean checkHashCodes = checkHashCodes(wocomponent);
    if (log.isDebugEnabled()) {
        log.debug("takeValuesFromRequest: {} - {}", wocontext.elementID(), wocontext.request().formValueKeys());
    }
    for (int index = 0; index < count; index++) {
        _prepareForIterationWithIndex(context, index, wocontext, wocomponent, checkHashCodes);
        super.takeValuesFromRequest(worequest, wocontext);
    }
    if (count > 0) {
        _cleanupAfterIteration(count, wocontext, wocomponent);
    }
}
Also used : WOContext(com.webobjects.appserver.WOContext) ERXWOContext(er.extensions.appserver.ERXWOContext) WOComponent(com.webobjects.appserver.WOComponent)

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