Search in sources :

Example 6 with WOAssociation

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

the class ERXComponentUtilities method appendHtmlAttributes.

/**
 * Appends a dictionary of associations as HTML attributes.
 *
 * @param associations
 *            the associations dictionary
 * @param response
 *            the response to write to
 * @param component
 *            the component to evaluate the associations within
 */
public static void appendHtmlAttributes(NSDictionary<String, WOAssociation> associations, WOResponse response, WOComponent component) {
    for (String key : associations.allKeys()) {
        WOAssociation association = associations.objectForKey(key);
        ERXComponentUtilities.appendHtmlAttribute(key, association, response, component);
    }
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation)

Example 7 with WOAssociation

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

the class AjaxOption method valueInComponent.

/*
   * Bridge to an AjaxDynamicElement.
   */
protected Object valueInComponent(WOComponent component, NSDictionary<String, ? extends WOAssociation> associations) {
    Object value = null;
    if (associations != null) {
        value = associations.objectForKey(_bindingName);
        // This is needed for the double step to resolve the value for ^ notation
        if (value instanceof WOAssociation) {
            WOAssociation association = (WOAssociation) value;
            value = association.valueInComponent(component);
        }
    }
    if (value == null) {
        value = _defaultValue;
    }
    return value;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation)

Example 8 with WOAssociation

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

the class AjaxOption method valueInComponent.

/*
   * Bridge to an AjaxComponent.
   */
protected Object valueInComponent(WOComponent component) {
    Object value = component.valueForBinding(_bindingName);
    if (value instanceof WOAssociation) {
        WOAssociation association = (WOAssociation) value;
        value = association.valueInComponent(component);
    }
    if (value == null) {
        value = _defaultValue;
    }
    return value;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation)

Example 9 with WOAssociation

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

the class AjaxOptions method _appendToBuffer.

/**
 * Adds JSON formatted key-value pairs from options to end of response content.  Does not adds the surrounding "{" and "}" signifying a dictionary / object.
 *
 * @param options dictionary of key-value pairs, intended to have come from AjaxOption
 * @param appendable appendable to add JSON formatted key-value pairs to
 * @param context WOContext to provide WOComponent to resolve binding values in
 */
public static void _appendToBuffer(NSDictionary options, Appendable appendable, WOContext context) {
    if (options != null) {
        WOComponent component = context.component();
        boolean hasPreviousOptions = false;
        Enumeration bindingsEnum = options.keyEnumerator();
        while (bindingsEnum.hasMoreElements()) {
            String bindingName = (String) bindingsEnum.nextElement();
            if (!"options".equals(bindingName)) {
                Object bindingValue = options.objectForKey(bindingName);
                // This is needed for the double step to resolve the value for ^ notation
                if (bindingValue instanceof WOAssociation) {
                    WOAssociation association = (WOAssociation) bindingValue;
                    bindingValue = association.valueInComponent(component);
                }
                if (bindingValue != null) {
                    try {
                        if (hasPreviousOptions) {
                            appendable.append(", ");
                        }
                        appendable.append(bindingName);
                        appendable.append(':');
                        appendable.append(bindingValue.toString());
                        hasPreviousOptions = true;
                    } catch (IOException e) {
                    // ignore
                    }
                }
            }
        }
    }
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) Enumeration(java.util.Enumeration) WOComponent(com.webobjects.appserver.WOComponent) IOException(java.io.IOException)

Example 10 with WOAssociation

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

the class AjaxOptions method appendToResponse.

@Override
public void appendToResponse(WOResponse response, WOContext context) {
    response.appendContentCharacter('{');
    NSMutableDictionary options = _associations;
    WOAssociation optionsBinding = _associations.objectForKey("options");
    if (optionsBinding != null) {
        NSDictionary passedInOptions = (NSDictionary) optionsBinding.valueInComponent(context.component());
        if (passedInOptions != null) {
            options = passedInOptions.mutableClone();
            options.addEntriesFromDictionary(_associations);
        }
    }
    AjaxOptions._appendToResponse(options, response, context);
    if (_children != null) {
        _children.appendToResponse(response, context);
    }
    response.appendContentCharacter('}');
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) NSDictionary(com.webobjects.foundation.NSDictionary) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Aggregations

WOAssociation (com.webobjects.appserver.WOAssociation)27 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)10 Enumeration (java.util.Enumeration)10 WOHTMLCommentString (com.webobjects.appserver._private.WOHTMLCommentString)8 WOComponent (com.webobjects.appserver.WOComponent)4 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)4 NSDictionary (com.webobjects.foundation.NSDictionary)4 WOKeyValueAssociation (com.webobjects.appserver._private.WOKeyValueAssociation)3 NSArray (com.webobjects.foundation.NSArray)3 WODeclaration (com.webobjects.appserver._private.WODeclaration)2 WOResponse (com.webobjects.appserver.WOResponse)1 WOBindingNameAssociation (com.webobjects.appserver._private.WOBindingNameAssociation)1 ERXMutableURL (er.extensions.foundation.ERXMutableURL)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1