use of com.webobjects.foundation.NSMutableDictionary 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.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxUpdateContainer method createObserveFieldOptions.
public NSMutableDictionary createObserveFieldOptions(WOComponent component) {
NSMutableArray ajaxOptionsArray = new NSMutableArray();
ajaxOptionsArray.addObject(new AjaxOption("observeFieldFrequency", AjaxOption.NUMBER));
NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, component, associations());
return options;
}
use of com.webobjects.foundation.NSMutableDictionary 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.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxSubmitButton method appendToResponse.
@Override
public void appendToResponse(WOResponse response, WOContext context) {
WOComponent component = context.component();
String functionName = (String) valueForBinding("functionName", null, component);
String formName = (String) valueForBinding("formName", component);
boolean showUI = (functionName == null || booleanValueForBinding("showUI", false, component));
boolean showButton = showUI && booleanValueForBinding("button", true, component);
boolean useButtonTagBinding = booleanValueForBinding("useButtonTag", false, component);
String formReference;
if ((!showButton || functionName != null) && formName == null) {
formName = ERXWOForm.formName(context, null);
if (formName == null) {
throw new WODynamicElementCreationException("If button = false or functionName is not null, the containing form must have an explicit name.");
}
}
if (formName == null) {
formReference = "this.form";
} else {
formReference = "document." + formName;
}
StringBuilder onClickBuffer = new StringBuilder();
String onClickBefore = (String) valueForBinding("onClickBefore", component);
if (onClickBefore != null) {
onClickBuffer.append("if (");
onClickBuffer.append(onClickBefore);
onClickBuffer.append(") {");
}
String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
// PROTOTYPE EFFECTS
String beforeEffect = (String) valueForBinding("beforeEffect", component);
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 replaceID = (String) valueForBinding("replaceID", component);
String id = (updateContainerID == null) ? replaceID : updateContainerID;
if (id != null) {
onClickBuffer.append("ASB.update('" + id + "',");
} else {
onClickBuffer.append("ASB.request(");
}
onClickBuffer.append(formReference);
if (valueForBinding("functionName", component) != null) {
onClickBuffer.append(",additionalParams");
} else {
onClickBuffer.append(",null");
}
onClickBuffer.append(',');
NSMutableDictionary options = createAjaxOptions(component);
if (replaceID != null) {
options.setObjectForKey("true", ERXAjaxApplication.KEY_REPLACED);
}
AjaxUpdateLink.addEffect(options, (String) valueForBinding("effect", component), id, (String) valueForBinding("effectDuration", component));
String afterEffectID = (String) valueForBinding("afterEffectID", component);
if (afterEffectID == null) {
afterEffectID = AjaxUpdateContainer.currentUpdateContainerID();
if (afterEffectID == null) {
afterEffectID = id;
}
}
AjaxUpdateLink.addEffect(options, (String) valueForBinding("afterEffect", component), afterEffectID, (String) valueForBinding("afterEffectDuration", component));
AjaxOptions.appendToBuffer(options, onClickBuffer, context);
onClickBuffer.append(')');
String onClick = (String) valueForBinding("onClick", component);
if (onClick != null) {
onClickBuffer.append(';');
onClickBuffer.append(onClick);
}
if (beforeEffect != null) {
onClickBuffer.append("}});");
}
if (onClickBefore != null) {
onClickBuffer.append('}');
}
if (functionName != null) {
AjaxUtils.appendScriptHeader(response);
response.appendContentString(functionName + " = function(additionalParams) { " + onClickBuffer + " }\n");
AjaxUtils.appendScriptFooter(response);
}
if (showUI) {
boolean disabled = disabledInComponent(component);
String elementName = (String) valueForBinding("elementName", "a", component);
boolean useButtonTag = useButtonTagBinding || ERXProperties.booleanForKeyWithDefault("er.extensions.foundation.ERXPatcher.DynamicElementsPatches.SubmitButton.useButtonTag", false);
if (showButton) {
elementName = useButtonTag ? "button" : "input";
response.appendContentString("<" + elementName + " ");
appendTagAttributeToResponse(response, "type", "button");
String name = nameInContext(context, component);
appendTagAttributeToResponse(response, "name", name);
appendTagAttributeToResponse(response, "value", valueForBinding("value", component));
appendTagAttributeToResponse(response, "accesskey", valueForBinding("accesskey", component));
if (disabled) {
appendTagAttributeToResponse(response, "disabled", "disabled");
}
} else {
boolean isATag = "a".equalsIgnoreCase(elementName);
if (isATag) {
response.appendContentString("<a href = \"javascript:void(0)\" ");
} else {
response.appendContentString("<" + elementName + " ");
}
}
appendTagAttributeToResponse(response, "class", valueForBinding("class", component));
appendTagAttributeToResponse(response, "style", valueForBinding("style", component));
appendTagAttributeToResponse(response, "id", valueForBinding("id", component));
appendTagAttributeToResponse(response, "tabindex", valueForBinding("tabindex", component));
appendTagAttributeToResponse(response, "title", valueForBinding("title", component));
if (functionName == null) {
appendTagAttributeToResponse(response, "onclick", onClickBuffer.toString());
} else {
appendTagAttributeToResponse(response, "onclick", functionName + "()");
}
if (showButton && !useButtonTag) {
response.appendContentString(" />");
} else {
response.appendContentString(">");
if (hasChildrenElements()) {
appendChildrenToResponse(response, context);
} else {
response.appendContentString((String) valueForBinding("value", component));
}
response.appendContentString("</" + elementName + ">");
}
}
super.appendToResponse(response, context);
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxSubmitButton method createAjaxOptions.
public NSMutableDictionary createAjaxOptions(WOComponent component) {
// PROTOTYPE OPTIONS
NSMutableArray<AjaxOption> ajaxOptionsArray = new NSMutableArray<>();
ajaxOptionsArray.addObject(new AjaxOption("onComplete", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("onSuccess", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("onFailure", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("onLoading", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("evalScripts", AjaxOption.BOOLEAN));
ajaxOptionsArray.addObject(new AjaxOption("insertion", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("asynchronous", AjaxOption.BOOLEAN));
String name = nameInContext(component.context(), component);
NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, component, associations());
AjaxSubmitButton.fillInAjaxOptions(this, component, name, options);
return options;
}
Aggregations