use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class ERXJavaScript method appendAttributesToResponse.
@Override
public void appendAttributesToResponse(WOResponse woresponse, WOContext wocontext) {
WOComponent wocomponent = wocontext.component();
woresponse._appendContentAsciiString(" type=\"text/javascript\"");
String framework = null;
String scriptName = null;
String src = null;
if (_scriptSource != null || _filename != null) {
String srcFromBindings;
if (_scriptSource != null) {
srcFromBindings = (String) _scriptSource.valueInComponent(wocomponent);
} else {
srcFromBindings = (String) _filename.valueInComponent(wocomponent);
}
if (srcFromBindings != null) {
if (!WOStaticURLUtilities.isRelativeURL(srcFromBindings)) {
src = srcFromBindings;
} else {
if (!WOStaticURLUtilities.isFragmentURL(srcFromBindings)) {
if (_scriptFramework != null) {
framework = (String) _scriptFramework.valueInComponent(wocomponent);
} else if (_framework != null) {
framework = (String) _framework.valueInComponent(wocomponent);
}
scriptName = srcFromBindings;
src = wocontext._urlForResourceNamed(srcFromBindings, framework, true);
if (src == null) {
src = wocomponent.baseURL() + "/" + srcFromBindings;
} else if (ERXResourceManager._shouldGenerateCompleteResourceURL(wocontext)) {
src = ERXResourceManager._completeURLForResource(src, null, wocontext);
}
} else {
log.warn("relative fragment URL {}", srcFromBindings);
}
}
}
}
Object key = null;
if (src == null && _scriptKey != null) {
key = _scriptKey.valueInComponent(wocomponent);
if (key != null) {
ERXExpiringCache<Object, WOResponse> cache = ERXJavaScript.cache(wocontext.session());
boolean render = cache.isStale(key);
render |= ERXApplication.isDevelopmentModeSafe();
if (render) {
WOResponse newresponse = new WOResponse();
super.appendChildrenToResponse(newresponse, wocontext);
newresponse.setHeader("application/x-javascript", "content-type");
cache.setObjectForKey(newresponse, key);
}
src = wocontext.directActionURLForActionNamed(Script.class.getName() + "/" + key, null);
}
}
if (src != null) {
woresponse._appendContentAsciiString(" src=\"");
woresponse.appendContentString(src);
woresponse.appendContentCharacter('"');
}
super.appendAttributesToResponse(woresponse, wocontext);
if (scriptName != null) {
ERXResponseRewriter.resourceAddedToHead(wocontext, framework, scriptName);
}
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class ERXWOComponentContent method invokeAction.
@Override
public WOActionResults invokeAction(WORequest worequest, WOContext wocontext) {
WOComponent component = wocontext.component();
WOElement template = template(component);
WOActionResults result;
if (template != null) {
wocontext._setCurrentComponent(component.parent());
result = template.invokeAction(worequest, wocontext);
wocontext._setCurrentComponent(component);
} else {
result = _defaultTemplate.invokeAction(worequest, wocontext);
}
return result;
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class ERXWOTextField method takeValuesFromRequest.
@Override
public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) {
WOComponent component = wocontext.component();
if (!isDisabledInContext(wocontext) && wocontext.wasFormSubmitted() && !isReadonlyInContext(wocontext)) {
String name = nameInContext(wocontext, component);
if (name != null) {
String stringValue;
boolean blankIsNull = _blankIsNull == null || _blankIsNull.booleanValueInComponent(component);
if (blankIsNull) {
stringValue = worequest.stringFormValueForKey(name);
} else {
Object objValue = worequest.formValueForKey(name);
stringValue = (objValue == null) ? null : objValue.toString();
}
Object result = stringValue;
if (stringValue != null) {
Format format = null;
boolean hasFormatter = false;
if (stringValue.length() != 0) {
if (_formatter != null) {
format = (Format) _formatter.valueInComponent(component);
}
if (format == null) {
if (_dateFormat != null) {
String formatString = (String) _dateFormat.valueInComponent(component);
if (formatString != null) {
format = ERXTimestampFormatter.dateFormatterForPattern(formatString);
}
} else if (_numberFormat != null) {
String formatString = (String) _numberFormat.valueInComponent(component);
if (formatString != null) {
format = ERXNumberFormatter.numberFormatterForPattern(formatString);
}
}
} else {
hasFormatter = true;
}
}
if (format != null) {
try {
Object parsedObject = format.parseObject(stringValue);
String reformatedObject = format.format(parsedObject);
result = format.parseObject(reformatedObject);
} catch (ParseException parseexception) {
String keyPath = _value.keyPath();
NSValidation.ValidationException validationexception = new NSValidation.ValidationException(parseexception.getMessage(), stringValue, keyPath);
component.validationFailedWithException(validationexception, stringValue, keyPath);
return;
}
if (result != null && _useDecimalNumber != null && _useDecimalNumber.booleanValueInComponent(component)) {
result = new BigDecimal(result.toString());
}
} else if (blankIsNull && result.toString().length() == 0) {
result = null;
}
}
_value.setValue(result, component);
}
}
}
Aggregations