Search in sources :

Example 6 with WOComponent

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

the class AjaxInPlaceEditor method handleRequest.

// Formatting/Parsing method "inspired by" WOTextField
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
    WOComponent component = context.component();
    String strValue = request.stringFormValueForKey("value");
    Object objValue = strValue;
    if (strValue != null) {
        Format format = null;
        if (strValue.length() != 0) {
            format = WOFormatterRepository.formatterForComponent(component, _dateFormat, _numberFormat, _formatter);
        }
        if (format != null) {
            try {
                Object parsedValue = format.parseObject(strValue);
                String formattedValue = format.format(parsedValue);
                objValue = format.parseObject(formattedValue);
            } catch (ParseException parseexception) {
                String valueKeyPath = _valueAssociation.keyPath();
                ValidationException validationexception = new ValidationException(parseexception.getMessage(), strValue, valueKeyPath);
                component.validationFailedWithException(validationexception, strValue, valueKeyPath);
                return null;
            }
            if (objValue != null && _useDecimalNumber != null && _useDecimalNumber.booleanValueInComponent(component)) {
                objValue = new BigDecimal(objValue.toString());
            }
        } else if (objValue.toString().length() == 0) {
            objValue = null;
        }
    }
    _valueAssociation.setValue(objValue, component);
    // just executing action, ignoring result
    valueForBinding("action", component);
    WOResponse response = AjaxUtils.createResponse(request, context);
    _appendValueAttributeToResponse(response, context);
    return response;
}
Also used : Format(java.text.Format) ValidationException(com.webobjects.foundation.NSValidation.ValidationException) WOComponent(com.webobjects.appserver.WOComponent) ParseException(java.text.ParseException) WOResponse(com.webobjects.appserver.WOResponse) BigDecimal(java.math.BigDecimal)

Example 7 with WOComponent

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

the class AjaxInPlaceEditor method _appendValueAttributeToResponse.

protected void _appendValueAttributeToResponse(WOResponse response, WOContext context) {
    WOComponent component = context.component();
    Object objValue = _valueAssociation.valueInComponent(component);
    if (objValue != null) {
        String strValue = null;
        Format format = WOFormatterRepository.formatterForInstance(objValue, component, _dateFormat, _numberFormat, _formatter);
        if (format != null) {
            try {
                String formattedStrValue = format.format(objValue);
                Object parsedValue = format.parseObject(formattedStrValue);
                strValue = format.format(parsedValue);
            } catch (IllegalArgumentException illegalargumentexception) {
                NSLog._conditionallyLogPrivateException(illegalargumentexception);
            } catch (ParseException parseexception) {
                NSLog._conditionallyLogPrivateException(parseexception);
            }
        }
        if (strValue == null) {
            strValue = objValue.toString();
        }
        if (_escapeHTML != null && _escapeHTML.booleanValueInComponent(component)) {
            response.appendContentHTMLString(strValue);
        } else {
            response.appendContentString(strValue);
        }
    }
}
Also used : Format(java.text.Format) WOComponent(com.webobjects.appserver.WOComponent) ParseException(java.text.ParseException)

Example 8 with WOComponent

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

the class AjaxIncludeScript method addRequiredWebResources.

@Override
protected void addRequiredWebResources(WOResponse res, WOContext context) {
    WOComponent component = context.component();
    String name = (String) _name.valueInComponent(component);
    String framework = "Ajax";
    if (_framework != null) {
        String value = (String) _framework.valueInComponent(component);
        if (value != null)
            framework = value;
    }
    addScriptResourceInHead(context, res, framework, name);
}
Also used : WOComponent(com.webobjects.appserver.WOComponent)

Example 9 with WOComponent

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

the class AjaxObserveField method appendToResponse.

public static void appendToResponse(WOResponse response, WOContext context, AjaxDynamicElement element, String observeFieldID, boolean observeDescendentFields, String updateContainerID, boolean fullSubmit, NSMutableDictionary<String, String> options) {
    WOComponent component = context.component();
    String submitButtonName = nameInContext(context, component, element);
    NSMutableDictionary<String, String> observerOptions = new NSMutableDictionary<>();
    if (options != null) {
        observerOptions.addEntriesFromDictionary(options);
    }
    AjaxSubmitButton.fillInAjaxOptions(element, component, submitButtonName, observerOptions);
    String observeFieldFrequency = observerOptions.removeObjectForKey("observeFieldFrequency");
    if (observeDescendentFields) {
        response.appendContentString("ASB.observeDescendentFields");
    } else {
        response.appendContentString("ASB.observeField");
    }
    String observeDelay = observerOptions.removeObjectForKey("observeDelay");
    response.appendContentString("(");
    response.appendContentString(AjaxUtils.quote(updateContainerID));
    response.appendContentString(", ");
    response.appendContentString(AjaxUtils.quote(observeFieldID));
    response.appendContentString(", ");
    response.appendContentString(observeFieldFrequency);
    response.appendContentString(", ");
    response.appendContentString(String.valueOf(!fullSubmit));
    response.appendContentString(", ");
    response.appendContentString(observeDelay);
    response.appendContentString(", ");
    AjaxOptions.appendToResponse(observerOptions, response, context);
    response.appendContentString(");");
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 10 with WOComponent

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

the class AjaxObserveField method appendToResponse.

@Override
public void appendToResponse(WOResponse response, WOContext context) {
    super.appendToResponse(response, context);
    WOComponent component = context.component();
    String observeFieldID = stringValueForBinding("observeFieldID", component);
    String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
    NSMutableDictionary<String, String> options = createAjaxOptions(component);
    boolean fullSubmit = booleanValueForBinding("fullSubmit", false, component);
    boolean observeFieldDescendents;
    if (observeFieldID != null) {
        observeFieldDescendents = false;
    } else {
        observeFieldDescendents = true;
        observeFieldID = stringValueForBinding("id", component);
        if (observeFieldID == null) {
            observeFieldID = ERXWOContext.safeIdentifierName(context, false);
        }
        String elementName = stringValueForBinding("elementName", "div", component);
        response.appendContentString("<" + elementName);
        appendTagAttributeToResponse(response, "id", observeFieldID);
        appendTagAttributeToResponse(response, "class", stringValueForBinding("class", component));
        appendTagAttributeToResponse(response, "style", stringValueForBinding("style", component));
        response.appendContentString(">");
        if (hasChildrenElements()) {
            appendChildrenToResponse(response, context);
        }
        response.appendContentString("</" + elementName + ">");
    }
    AjaxUtils.appendScriptHeader(response);
    AjaxObserveField.appendToResponse(response, context, this, observeFieldID, observeFieldDescendents, updateContainerID, fullSubmit, options);
    AjaxUtils.appendScriptFooter(response);
}
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