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;
}
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);
}
}
}
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);
}
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(");");
}
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);
}
Aggregations