Search in sources :

Example 56 with WOComponent

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

the class AjaxDefaultSubmitButton method appendToResponse.

@Override
public void appendToResponse(WOResponse response, WOContext context) {
    WOComponent component = context.component();
    String formName = (String) valueForBinding("formName", component);
    String formReference = "this.form";
    if (formName != null) {
        formReference = "document." + formName;
    }
    StringBuilder onClickBuffer = new StringBuilder();
    String onClickBefore = (String) valueForBinding("onClickBefore", component);
    if (onClickBefore != null) {
        onClickBuffer.append("if (");
        onClickBuffer.append(onClickBefore);
        onClickBuffer.append(") {");
    }
    // PROTOTYPE EFFECTS
    String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
    String beforeEffect = (String) valueForBinding("beforeEffect", component);
    if (beforeEffect != null) {
        onClickBuffer.append("new ");
        onClickBuffer.append(AjaxUpdateLink.fullEffectName(beforeEffect));
        onClickBuffer.append("('");
        String beforeEffectID = (String) valueForBinding("beforeEffectID", component);
        if (beforeEffectID == null) {
            beforeEffectID = AjaxUpdateContainer.currentUpdateContainerID();
            if (beforeEffectID == null) {
                beforeEffectID = updateContainerID;
            }
        }
        onClickBuffer.append(beforeEffectID);
        onClickBuffer.append("', { ");
        String beforeEffectDuration = (String) valueForBinding("beforeEffectDuration", component);
        if (beforeEffectDuration != null) {
            onClickBuffer.append("duration: ");
            onClickBuffer.append(beforeEffectDuration);
            onClickBuffer.append(", ");
        }
        onClickBuffer.append("queue:'end', afterFinish: function() {");
    }
    if (updateContainerID != null) {
        onClickBuffer.append("ASB.update('" + updateContainerID + "',");
    } else {
        onClickBuffer.append("ASB.request(");
    }
    onClickBuffer.append(formReference);
    onClickBuffer.append(",null,");
    NSMutableDictionary options = createAjaxOptions(component);
    AjaxUpdateLink.addEffect(options, (String) valueForBinding("effect", component), updateContainerID, (String) valueForBinding("effectDuration", component));
    String afterEffectID = (String) valueForBinding("afterEffectID", component);
    if (afterEffectID == null) {
        afterEffectID = AjaxUpdateContainer.currentUpdateContainerID();
        if (afterEffectID == null) {
            afterEffectID = updateContainerID;
        }
    }
    AjaxUpdateLink.addEffect(options, (String) valueForBinding("afterEffect", component), afterEffectID, (String) valueForBinding("afterEffectDuration", component));
    AjaxOptions.appendToBuffer(options, onClickBuffer, context);
    onClickBuffer.append(')');
    String onClick = (String) valueForBinding("onClick", component);
    if (onClick != null) {
        onClickBuffer.append(';');
        onClickBuffer.append(onClick);
    }
    if (beforeEffect != null) {
        onClickBuffer.append("}});");
    }
    if (onClickBefore != null) {
        onClickBuffer.append('}');
    }
    onClickBuffer.append("; return false;");
    response.appendContentString("<input ");
    appendTagAttributeToResponse(response, "tabindex", "");
    appendTagAttributeToResponse(response, "type", "submit");
    String name = nameInContext(context, component);
    appendTagAttributeToResponse(response, "name", name);
    appendTagAttributeToResponse(response, "value", valueForBinding("value", component));
    appendTagAttributeToResponse(response, "accesskey", valueForBinding("accesskey", component));
    // Suppress modal box focus ring if used inside of modal dialog
    if (AjaxModalDialog.isInDialog(context)) {
        StringBuilder sb = new StringBuilder("MB_notFocusable ");
        Object cssClass = valueForBinding("class", component);
        if (cssClass != null) {
            sb.append(cssClass);
        }
        appendTagAttributeToResponse(response, "class", sb.toString());
    } else {
        appendTagAttributeToResponse(response, "class", valueForBinding("class", component));
    }
    appendTagAttributeToResponse(response, "style", "position:absolute;left:-10000px");
    appendTagAttributeToResponse(response, "id", valueForBinding("id", component));
    appendTagAttributeToResponse(response, "onclick", onClickBuffer.toString());
    response.appendContentString(" />");
    // fix for IE < 9 that deactivates the standard submit routine of the form and
    // triggers the onClick handler of this submit element instead if the return key
    // is pressed within a textfield, radiobutton, checkbox or select
    ERXBrowser browser = ERXBrowserFactory.factory().browserMatchingRequest(context.request());
    if (browser.isIE() && browser.majorVersion().compareTo(Integer.valueOf(9)) < 0) {
        if (!hasBinding("formName")) {
            formName = ERXWOForm.formName(context, "");
        }
        AjaxUtils.appendScriptHeader(response);
        response.appendContentString("\nEvent.observe(document." + formName + ", 'keypress', function(e){");
        // return key
        response.appendContentString("if(e.keyCode==13){");
        response.appendContentString("var shouldFire=false;var t=e.target;var tn=t.tagName.toLowerCase();");
        response.appendContentString("if(tn==='select'){shouldFire=true;}");
        response.appendContentString("else if(tn==='input'){var ty=t.type.toLowerCase();");
        response.appendContentString("if(ty==='text' || ty==='radio' || ty==='checkbox'){shouldFire=true;}}");
        response.appendContentString("if(shouldFire){$$('[name=" + name + "]')[0].fireEvent('onClick');e.returnValue=false;}");
        response.appendContentString("}});");
        AjaxUtils.appendScriptFooter(response);
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) ERXBrowser(er.extensions.appserver.ERXBrowser) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 57 with WOComponent

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

the class ERXComponentRequestHandler method _dispatchWithPreparedPage.

private WOResponse _dispatchWithPreparedPage(WOComponent aPage, WOSession aSession, WOContext aContext, NSDictionary someElements) {
    WORequest aRequest = aContext.request();
    WOApplication anApplication = WOApplication.application();
    WOResponse aResponse = anApplication.createResponseInContext(aContext);
    String aSenderID = aContext.senderID();
    String oldContextID = aSession._contextIDMatchingIDs(aContext);
    aResponse.setHTTPVersion(aRequest.httpVersion());
    aResponse.setHeader("text/html", "content-type");
    aContext._setResponse(aResponse);
    if (oldContextID == null) {
        if (aSenderID != null) {
            if (aRequest._hasFormValues()) {
                anApplication.takeValuesFromRequest(aRequest, aContext);
            }
        }
        aContext._setPageChanged(false);
        if (aSenderID != null) {
            WOActionResults anActionResults = anApplication.invokeAction(aRequest, aContext);
            if ((anActionResults == null) || ((anActionResults instanceof WOComponent))) {
                WOComponent aResultComponent = (WOComponent) anActionResults;
                if ((aResultComponent != null) && (aResultComponent.context() != aContext)) {
                    aResultComponent._awakeInContext(aContext);
                }
                boolean didPageChange = false;
                if ((aResultComponent != null) && (aResultComponent != aContext._pageElement())) {
                    didPageChange = true;
                }
                aContext._setPageChanged(didPageChange);
                if (didPageChange) {
                    aContext._setPageElement(aResultComponent);
                }
            } else {
                WOResponse theResponse = anActionResults.generateResponse();
                return theResponse;
            }
        }
    } else {
        WOComponent responsePage = _restorePageForContextID(oldContextID, aSession);
        aContext._setPageElement(responsePage);
    }
    anApplication.appendToResponse(aResponse, aContext);
    return aResponse;
}
Also used : WORequest(com.webobjects.appserver.WORequest) WOActionResults(com.webobjects.appserver.WOActionResults) WOComponent(com.webobjects.appserver.WOComponent) WOResponse(com.webobjects.appserver.WOResponse) WOApplication(com.webobjects.appserver.WOApplication)

Example 58 with WOComponent

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

the class WOMethodInvocation method invokeAction.

@Override
public WOActionResults invokeAction(WORequest aRequest, WOContext aContext) {
    WOComponent aComponent = aContext.component();
    _invoke.valueInComponent(aComponent);
    return null;
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 59 with WOComponent

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

the class WOMethodInvocation method appendToResponse.

@Override
public void appendToResponse(WOResponse aResponse, WOContext aContext) {
    WOComponent aComponent = aContext.component();
    _invoke.valueInComponent(aComponent);
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 60 with WOComponent

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

the class WOMethodInvocation method takeValuesFromRequest.

@Override
public void takeValuesFromRequest(WORequest aRequest, WOContext aContext) {
    WOComponent aComponent = aContext.component();
    _invoke.valueInComponent(aComponent);
}
Also used : 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