Search in sources :

Example 51 with WOComponent

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

the class AjaxModalContainer method handleRequest.

@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
    WOComponent component = context.component();
    WOResponse response = null;
    WOAssociation action = associations().objectForKey("action");
    if (action != null) {
        action.valueInComponent(component);
    }
    if (booleanValueForBinding("ajax", false, component) && hasChildrenElements()) {
        response = AjaxUtils.createResponse(request, context);
        AjaxUtils.setPageReplacementCacheKey(context, _containerID(context));
        appendChildrenToResponse(response, context);
    }
    return response;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) WOComponent(com.webobjects.appserver.WOComponent) WOResponse(com.webobjects.appserver.WOResponse)

Example 52 with WOComponent

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

the class AjaxTabbedPanelTab method appendToResponse.

/**
 * Creates the panes.
 */
@Override
public void appendToResponse(WOResponse aResponse, WOContext aContext) {
    WOComponent component = aContext.component();
    if (isVisble(component)) {
        aResponse.appendContentString("<li id=\"");
        aResponse.appendContentString(tabIdInComponent(component) + "_panel");
        aResponse.appendContentString("\" data-updateUrl=\"");
        aResponse.appendContentString(AjaxUtils.ajaxComponentActionUrl(aContext));
        aResponse.appendContentString("\" class=\"");
        aResponse.appendContentString(isSelected(component) ? "ajaxTabbedPanelPane-selected" : "ajaxTabbedPanelPane-unselected");
        aResponse.appendContentString("\"");
        if (onLoad != null) {
            appendTagAttributeToResponse(aResponse, "onLoad", onLoad.valueInComponent(component));
        }
        aResponse.appendContentString(">");
        // it is controlled by the user clicking tabs
        if (isSelected(component) && content != null) {
            content.appendToResponse(aResponse, aContext);
        }
        aResponse.appendContentString("</li>\n");
        // it is fired by the user clicking tabs
        if (isSelected(component) && content != null) {
            aResponse.appendContentString("<script>AjaxTabbedPanel.onLoad('");
            aResponse.appendContentString(tabIdInComponent(component) + "_panel");
            aResponse.appendContentString("');</script>\n");
        }
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 53 with WOComponent

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

the class AjaxToggleLink method _appendAttributesToResponse.

public static void _appendAttributesToResponse(WOResponse response, WOContext context, WOAssociation toggleIDAssociation, WOAssociation effectAssociation, WOAssociation durationAssociation) {
    WOComponent component = context.component();
    String effect = null;
    if (effectAssociation != null) {
        effect = (String) effectAssociation.valueInComponent(component);
    }
    if (effect == null) {
        effect = "blind";
    }
    String toggleID = (String) toggleIDAssociation.valueInComponent(component);
    // PROTOTYPE EFFECTS
    response.appendContentString(" onclick = \"Effect.toggle($wi('");
    response.appendContentString(toggleID);
    response.appendContentString("'), '");
    response.appendContentString(effect);
    response.appendContentString("', ");
    NSMutableDictionary<String, WOAssociation> options = new NSMutableDictionary<>();
    if (durationAssociation != null) {
        options.setObjectForKey(durationAssociation, "duration");
    }
    AjaxOptions.appendToResponse(options, response, context);
    response.appendContentString(")\"");
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) WOComponent(com.webobjects.appserver.WOComponent) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 54 with WOComponent

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

the class AjaxUpdateContainer method appendToResponse.

@Override
public void appendToResponse(WOResponse response, WOContext context) {
    WOComponent component = context.component();
    if (!shouldRenderContainer(component)) {
        if (hasChildrenElements()) {
            appendChildrenToResponse(response, context);
        }
        super.appendToResponse(response, context);
    } else {
        String previousUpdateContainerID = AjaxUpdateContainer.currentUpdateContainerID();
        try {
            String elementName = (String) valueForBinding("elementName", "div", component);
            String id = _containerID(context);
            AjaxUpdateContainer.setCurrentUpdateContainerID(_containerID(context));
            response.appendContentString("<" + elementName + " ");
            appendTagAttributeToResponse(response, "id", id);
            appendTagAttributeToResponse(response, "class", valueForBinding("class", component));
            appendTagAttributeToResponse(response, "style", valueForBinding("style", component));
            appendTagAttributeToResponse(response, "data-updateUrl", AjaxUtils.ajaxComponentActionUrl(context));
            // appendTagAttributeToResponse(response, "woElementID", context.elementID());
            response.appendContentString(">");
            if (hasChildrenElements()) {
                appendChildrenToResponse(response, context);
            }
            response.appendContentString("</" + elementName + ">");
            super.appendToResponse(response, context);
            NSDictionary options = createAjaxOptions(component);
            Object frequency = valueForBinding("frequency", component);
            String observeFieldID = (String) valueForBinding("observeFieldID", component);
            boolean skipFunction = frequency == null && observeFieldID == null && booleanValueForBinding("skipFunction", false, component);
            if (!skipFunction) {
                AjaxUtils.appendScriptHeader(response);
                if (frequency != null) {
                    // try to convert to a number to check whether it is 0
                    boolean isNotZero = true;
                    try {
                        float numberFrequency = ERXValueUtilities.floatValue(frequency);
                        if (numberFrequency == 0.0) {
                            // set this only to false if it can be converted to 0
                            isNotZero = false;
                        }
                    } catch (RuntimeException e) {
                        throw new IllegalStateException("Error parsing float from value : <" + frequency + ">");
                    }
                    if (isNotZero) {
                        boolean canStop = false;
                        boolean stopped = false;
                        if (associations().objectForKey("stopped") != null) {
                            canStop = true;
                            stopped = booleanValueForBinding("stopped", false, component);
                        }
                        response.appendContentString("AUC.registerPeriodic('" + id + "'," + canStop + "," + stopped + ",");
                        AjaxOptions.appendToResponse(options, response, context);
                        response.appendContentString(");");
                    }
                }
                if (observeFieldID != null) {
                    boolean fullSubmit = booleanValueForBinding("fullSubmit", false, component);
                    AjaxObserveField.appendToResponse(response, context, this, observeFieldID, false, id, fullSubmit, createObserveFieldOptions(component));
                }
                response.appendContentString("AUC.register('" + id + "'");
                NSDictionary nonDefaultOptions = AjaxUpdateContainer.removeDefaultOptions(options);
                if (nonDefaultOptions.count() > 0) {
                    response.appendContentString(", ");
                    AjaxOptions.appendToResponse(nonDefaultOptions, response, context);
                }
                response.appendContentString(");");
                AjaxUtils.appendScriptFooter(response);
            }
        } finally {
            AjaxUpdateContainer.setCurrentUpdateContainerID(previousUpdateContainerID);
        }
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) NSDictionary(com.webobjects.foundation.NSDictionary)

Example 55 with WOComponent

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

the class AjaxUpdateLink method handleRequest.

@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
    WOComponent component = context.component();
    boolean disabled = booleanValueForBinding("disabled", false, component);
    String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
    AjaxUpdateContainer.setUpdateContainerID(request, updateContainerID);
    WOActionResults results = null;
    if (!disabled) {
        results = (WOActionResults) valueForBinding("action", component);
    }
    if (ERXAjaxApplication.isAjaxReplacement(request)) {
        AjaxUtils.setPageReplacementCacheKey(context, (String) valueForBinding("replaceID", component));
    } else if (results == null || booleanValueForBinding("ignoreActionResponse", false, component)) {
        String script = (String) valueForBinding("onClickServer", component);
        if (script != null) {
            WOResponse response = AjaxUtils.createResponse(request, context);
            AjaxUtils.appendScriptHeaderIfNecessary(request, response);
            response.appendContentString(script);
            AjaxUtils.appendScriptFooterIfNecessary(request, response);
            results = response;
        }
    } else if (updateContainerID != null) {
        AjaxUtils.setPageReplacementCacheKey(context, updateContainerID);
    }
    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