Search in sources :

Example 1 with WOComponent

use of com.webobjects.appserver.WOComponent 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 context
 *            the context
 */
public static void appendHtmlAttributes(NSDictionary<String, WOAssociation> associations, WOResponse response, WOContext context) {
    WOComponent component = context.component();
    ERXComponentUtilities.appendHtmlAttributes(associations, response, component);
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 2 with WOComponent

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

the class ERXComponentUtilities method componentTree.

/**
 * Returns an array of the current component names.
 *
 * @return array of current component names
 */
public static NSArray<String> componentTree() {
    WOContext context = ERXWOContext.currentContext();
    NSMutableArray<String> result = new NSMutableArray<>();
    if (context != null) {
        WOComponent c = context.component();
        while (c != null) {
            result.addObject(c.name());
            c = c.parent();
        }
    }
    return result;
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) NSMutableArray(com.webobjects.foundation.NSMutableArray) WOContext(com.webobjects.appserver.WOContext) ERXWOContext(er.extensions.appserver.ERXWOContext)

Example 3 with WOComponent

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

the class AjaxFunctionLink method _appendAttributesToResponse.

public static void _appendAttributesToResponse(WOResponse response, WOContext context, WOAssociation actionAssociation, WOAssociation updateContainerIDAssociation) {
    WOComponent component = context.component();
    if (actionAssociation != null) {
        String action = (String) actionAssociation.valueInComponent(component);
        String updateContainerID;
        if (updateContainerIDAssociation != null) {
            updateContainerID = (String) updateContainerIDAssociation.valueInComponent(component);
        } else {
            updateContainerID = AjaxUpdateContainer.currentUpdateContainerID();
        }
        if (updateContainerID == null) {
            throw new WODynamicElementCreationException("You must either set the 'updateContainerID' binding or the link must be contained inside of an AjaxUpdateContainer.");
        }
        response.appendContentString(" onclick = \"");
        response.appendContentString(updateContainerID);
        if ("edit".equalsIgnoreCase(action)) {
            response.appendContentString("Edit");
        } else if ("cancel".equalsIgnoreCase(action)) {
            response.appendContentString("Cancel");
        } else if ("save".equalsIgnoreCase(action)) {
            response.appendContentString("Save");
        } else if ("update".equalsIgnoreCase(action)) {
            response.appendContentString("Update");
        } else {
            throw new WODynamicElementCreationException("Unknown AjaxInPlace action '" + action + "'.  Must be one of 'edit', 'cancel', 'save', or 'Update'.");
        }
        response.appendContentString("()\"");
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WODynamicElementCreationException(com.webobjects.appserver._private.WODynamicElementCreationException)

Example 4 with WOComponent

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

the class AjaxHighlight method appendToResponse.

@Override
public void appendToResponse(WOResponse response, WOContext context) {
    AjaxUtils.addScriptResourceInHead(context, response, "prototype.js");
    AjaxUtils.addScriptResourceInHead(context, response, "effects.js");
    AjaxUtils.addScriptResourceInHead(context, response, "wonder.js");
    WOComponent component = context.component();
    boolean generateContainer = (_id == null || _elementName != null);
    String elementName;
    if (_elementName == null) {
        elementName = "div";
    } else {
        elementName = (String) _elementName.valueInComponent(component);
    }
    String id;
    if (_id == null) {
        id = ERXWOContext.safeIdentifierName(context, false);
    } else {
        id = (String) _id.valueInComponent(component);
    }
    HighlightMetadata metadata = null;
    if (_value != null) {
        Object value = _value.valueInComponent(component);
        if (value != null) {
            metadata = highlightMetadataForObject(value);
        }
    }
    if (generateContainer) {
        response.appendContentString("<");
        response.appendContentString(elementName);
        response._appendTagAttributeAndValue("id", id, true);
        AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "class");
        String displayStyle = null;
        if (metadata != null) {
            boolean hidden = false;
            if (metadata.isNew() && _newHidden != null) {
                hidden = _newHidden.booleanValueInComponent(component);
            } else if (!metadata.isNew() && _updateHidden != null) {
                hidden = _updateHidden.booleanValueInComponent(component);
            } else if (_hidden != null) {
                hidden = _hidden.booleanValueInComponent(component);
            }
            if (hidden) {
                displayStyle = "display: none;";
            }
        }
        AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "style", displayStyle);
        AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "onMouseOver");
        AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "onMouseOut");
        response.appendContentString(">");
    }
    super.appendToResponse(response, context);
    if (generateContainer) {
        response.appendContentString("</");
        response.appendContentString(elementName);
        response.appendContentString(">");
    }
    if (metadata != null) {
        String effect;
        if (metadata.isNew() && _newEffect != null) {
            effect = (String) _newEffect.valueInComponent(component);
        } else if (!metadata.isNew() && _updateEffect != null) {
            effect = (String) _updateEffect.valueInComponent(component);
        } else if (_effect != null) {
            effect = (String) _effect.valueInComponent(component);
        } else {
            effect = "Highlight";
        }
        if (!"none".equalsIgnoreCase(effect)) {
            AjaxUtils.appendScriptHeader(response);
            Object duration = null;
            if (metadata.isNew() && _newDuration != null) {
                duration = _newDuration.valueInComponent(component);
            } else if (!metadata.isNew() && _updateDuration != null) {
                duration = _updateDuration.valueInComponent(component);
            } else if (_duration != null) {
                duration = _duration.valueInComponent(component);
            }
            Object delay = _delay == null ? null : _delay.valueInComponent(component);
            String effectName = AjaxUpdateLink.fullEffectName(effect);
            Object showDuration = _showDuration == null ? null : _showDuration.valueInComponent(component);
            String showEffectName = _showEffect == null ? null : AjaxUpdateLink.fullEffectName((String) _showEffect.valueInComponent(component));
            Object hideDelay = (_hideDelay == null) ? null : _hideDelay.valueInComponent(component);
            Object hideDuration = _hideDuration == null ? null : _hideDuration.valueInComponent(component);
            String hideEffectName = _hideEffect == null ? null : AjaxUpdateLink.fullEffectName((String) _hideEffect.valueInComponent(component));
            response.appendContentString("AH.highlight(" + AjaxUtils.quote(id) + "," + delay + "," + AjaxUtils.quote(showEffectName) + "," + showDuration + "," + AjaxUtils.quote(effectName) + "," + duration + "," + hideDelay + "," + AjaxUtils.quote(hideEffectName) + "," + hideDuration + ");");
            AjaxUtils.appendScriptFooter(response);
        }
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 5 with WOComponent

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

the class AjaxHyperlink method handleRequest.

@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
    WOComponent component = context.component();
    WOActionResults results = (WOActionResults) valueForBinding("action", component);
    if (results == null) {
        String script = (String) valueForBinding("onClickServer", component);
        if (script != null) {
            WOResponse response = AjaxUtils.createResponse(request, context);
            AjaxUtils.appendScriptHeader(response);
            response.appendContentString(script);
            AjaxUtils.appendScriptFooter(response);
            results = response;
        }
    }
    return results;
}
Also used : WOActionResults(com.webobjects.appserver.WOActionResults) WOComponent(com.webobjects.appserver.WOComponent) WOResponse(com.webobjects.appserver.WOResponse)

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