use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class AjaxDatePicker method validationFailedWithException.
/**
* Overridden so that parent will handle in the same manner as if this were a dynamic element.
* @param t the exception thrown during validation
* @param value the given value to be validated
* @param keyPath the key path associated with this value, identifies the property of an object
*/
@Override
public void validationFailedWithException(Throwable t, Object value, String keyPath) {
if (keyPath != null && "<none>".equals(keyPath) && t instanceof ValidationException) {
ValidationException e = (ValidationException) t;
WOAssociation valueAssociation = (WOAssociation) _keyAssociations.valueForKey("value");
if (valueAssociation != null) {
keyPath = valueAssociation.keyPath();
}
t = new ValidationException(e.getMessage(), e.object(), keyPath);
}
parent().validationFailedWithException(t, value, keyPath);
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class AjaxToggleLink method processAssociations.
protected static NSDictionary<String, WOAssociation> processAssociations(NSDictionary<String, WOAssociation> associations) {
NSMutableDictionary<String, WOAssociation> mutableAssociations = (NSMutableDictionary<String, WOAssociation>) associations;
mutableAssociations.setObjectForKey(new WOConstantValueAssociation("javascript:void(0)"), "href");
return mutableAssociations;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class AjaxUpdateLink method onClick.
public String onClick(WOContext context, boolean generateFunctionWrapper) {
WOComponent component = context.component();
NSMutableDictionary options = createAjaxOptions(component);
StringBuilder onClickBuffer = new StringBuilder();
String onClick = (String) valueForBinding("onClick", component);
String onClickBefore = (String) valueForBinding("onClickBefore", component);
String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
String functionName = (String) valueForBinding("functionName", component);
String function = (String) valueForBinding("function", component);
String replaceID = (String) valueForBinding("replaceID", component);
// PROTOTYPE EFFECTS
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;
}
}
// PROTOTYPE EFFECTS
AjaxUpdateLink.addEffect(options, (String) valueForBinding("afterEffect", component), afterEffectID, (String) valueForBinding("afterEffectDuration", component));
// PROTOTYPE EFFECTS
String beforeEffect = (String) valueForBinding("beforeEffect", component);
WOAssociation directActionNameAssociation = (WOAssociation) associations().valueForKey("directActionName");
if (beforeEffect == null && updateContainerID != null && directActionNameAssociation == null && replaceID == null && function == null && onClick == null && onClickBefore == null) {
NSDictionary nonDefaultOptions = AjaxUpdateContainer.removeDefaultOptions(options);
onClickBuffer.append("AUL.");
if (generateFunctionWrapper) {
onClickBuffer.append("updateFunc");
} else {
onClickBuffer.append("update");
}
onClickBuffer.append("('");
onClickBuffer.append(updateContainerID);
onClickBuffer.append("', ");
AjaxOptions.appendToBuffer(nonDefaultOptions, onClickBuffer, context);
onClickBuffer.append(", '");
onClickBuffer.append(context.contextID());
onClickBuffer.append('.');
onClickBuffer.append(context.elementID());
onClickBuffer.append('\'');
// if (generateFunctionWrapper) {
// onClickBuffer.append(", additionalParams");
// }
onClickBuffer.append(')');
onClickBuffer.append(';');
} else {
if (generateFunctionWrapper) {
onClickBuffer.append("function(additionalParams) {");
}
if (onClickBefore != null) {
onClickBuffer.append("if (");
onClickBuffer.append(onClickBefore);
onClickBuffer.append(") {");
}
// PROTOTYPE EFFECTS
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() {");
}
String actionUrl = null;
if (directActionNameAssociation != null) {
actionUrl = context._directActionURL((String) directActionNameAssociation.valueInComponent(component), ERXComponentUtilities.queryParametersInComponent(associations(), component), ERXRequest.isRequestSecure(context.request()), 0, false).replaceAll("&", "&");
} else {
actionUrl = AjaxUtils.ajaxComponentActionUrl(context);
}
if (replaceID != null) {
try {
ERXMutableURL tempActionUrl = new ERXMutableURL(actionUrl);
tempActionUrl.addQueryParameter(ERXAjaxApplication.KEY_REPLACED, "true");
actionUrl = tempActionUrl.toExternalForm();
} catch (MalformedURLException e) {
throw NSForwardException._runtimeExceptionForThrowable(e);
}
}
actionUrl = "'" + actionUrl + "'";
if (functionName != null) {
actionUrl = actionUrl + ".addQueryParameters(additionalParams)";
}
if (function != null) {
onClickBuffer.append("return " + function + "(" + actionUrl + ")");
} else {
// PROTOTYPE FUNCTIONS
if (replaceID == null) {
if (updateContainerID == null) {
onClickBuffer.append("new Ajax.Request(" + actionUrl + ", ");
AjaxOptions.appendToBuffer(options, onClickBuffer, context);
onClickBuffer.append(')');
} else {
onClickBuffer.append("new Ajax.Updater('" + updateContainerID + "', " + actionUrl + ", ");
AjaxOptions.appendToBuffer(options, onClickBuffer, context);
onClickBuffer.append(')');
}
} else {
onClickBuffer.append("new Ajax.Updater('" + replaceID + "', " + actionUrl + ", ");
AjaxOptions.appendToBuffer(options, onClickBuffer, context);
onClickBuffer.append(')');
}
}
if (onClick != null) {
onClickBuffer.append(';');
onClickBuffer.append(onClick);
}
if (beforeEffect != null) {
onClickBuffer.append("}});");
}
if (onClickBefore != null) {
onClickBuffer.append('}');
}
if (generateFunctionWrapper) {
onClickBuffer.append('}');
}
}
return onClickBuffer.toString();
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class WOHelperFunctionParser method parseInlineAssociation.
protected void parseInlineAssociation(StringBuffer keyBuffer, StringBuffer valueBuffer, NSMutableDictionary bindings) throws WOHelperFunctionHTMLFormatException {
String key = keyBuffer.toString().trim();
String value = valueBuffer.toString().trim();
NSDictionary quotedStrings;
if (value.startsWith("\"")) {
value = value.substring(1);
if (value.endsWith("\"")) {
value = value.substring(0, value.length() - 1);
} else {
throw new WOHelperFunctionHTMLFormatException(valueBuffer + " starts with quote but does not end with one.");
}
if (value.startsWith("$")) {
value = value.substring(1);
if (value.endsWith("VALID")) {
value = value.replaceFirst("\\s*//\\s*VALID", "");
}
quotedStrings = new NSDictionary();
} else {
value = value.replaceAll("\\\\\\$", "\\$");
value = value.replaceAll("\\\"", "\"");
quotedStrings = new NSDictionary(value, "_WODP_0");
value = "_WODP_0";
}
} else {
quotedStrings = new NSDictionary();
}
WOAssociation association = WOHelperFunctionDeclarationParser._associationWithKey(value, quotedStrings);
bindings.setObjectForKey(association, key);
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class WOHelperFunctionParser method processDeclaration.
protected void processDeclaration(WODeclaration declaration) {
NSMutableDictionary associations = (NSMutableDictionary) declaration.associations();
Enumeration bindingNameEnum = associations.keyEnumerator();
while (bindingNameEnum.hasMoreElements()) {
String bindingName = (String) bindingNameEnum.nextElement();
WOAssociation association = (WOAssociation) associations.valueForKey(bindingName);
WOAssociation helperAssociation = parserHelperAssociation(association);
if (helperAssociation != association) {
associations.setObjectForKey(helperAssociation, bindingName);
}
}
}
Aggregations