use of com.webobjects.foundation.NSValidation.ValidationException 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;
}
Aggregations