use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxAccordion method createAjaxOptions.
public NSDictionary createAjaxOptions() {
NSMutableArray ajaxOptionsArray = new NSMutableArray();
ajaxOptionsArray.addObject(new AjaxOption("expandedBg", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("hoverBg", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("collapsedBg", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("expandedTextColor", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("expandedFontWeight", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("hoverTextColor", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("collapsedTextColor", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("collapsedFontWeight", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("hoverTextColor", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("borderColor", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("panelHeight", AjaxOption.NUMBER));
ajaxOptionsArray.addObject(new AjaxOption("onHideTab", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("onShowTab", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("onLoadShowTab", AjaxOption.SCRIPT));
NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
return options;
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxAutoComplete method appendToResponse.
/**
* Overridden to add the initialization javascript for the auto completer.
*/
@Override
public void appendToResponse(WOResponse res, WOContext ctx) {
super.appendToResponse(res, ctx);
boolean isDisabled = booleanValueForBinding("disabled", false);
if (!isDisabled) {
String actionUrl = AjaxUtils.ajaxComponentActionUrl(ctx);
NSMutableDictionary<String, String> options = createAjaxOptions().mutableClone();
if ("observe".equalsIgnoreCase(options.get("afterUpdateElement"))) {
// Javascript to simulate AjaxObserveField on this AjaxAutocomplete when an item has been selected from the list
String afterUpdateElement = "function (text, li) { " + "var options = new Array();" + "options.parameters = encodeURIComponent('" + fieldName + "') + '=' + encodeURIComponent(text.value);" + "new Ajax.Request('" + actionUrl + "', options);" + "}";
options.put("afterUpdateElement", afterUpdateElement);
}
boolean isLocal = booleanValueForBinding("isLocal", false);
if (isLocal) {
StringBuilder str = new StringBuilder();
boolean isLocalSharedList = booleanValueForBinding("isLocalSharedList", false);
String listJS = null;
if (isLocalSharedList) {
String varName = (String) valueForBinding("localSharedVarName");
NSMutableDictionary userInfo = ERXWOContext.contextDictionary();
if (userInfo.objectForKey(varName) == null) {
String ljs = listeJS();
AjaxUtils.addScriptCodeInHead(res, ctx, "var " + varName + " = " + ljs + ";");
userInfo.setObjectForKey(ljs, varName);
}
listJS = varName;
} else {
listJS = listeJS();
}
str.append("<script type=\"text/javascript\">\n// <![CDATA[\n");
str.append("new Autocompleter.Local('");
str.append(fieldName);
str.append("','");
str.append(divName);
str.append("',");
str.append(listJS);
str.append(',');
AjaxOptions.appendToBuffer(options, str, ctx);
str.append(");\n// ]]>\n</script>\n");
res.appendContentString(String.valueOf(str));
} else {
AjaxUtils.appendScriptHeader(res);
res.appendContentString("new Ajax.Autocompleter('" + fieldName + "', '" + divName + "', '" + actionUrl + "', ");
AjaxOptions.appendToResponse(options, res, ctx);
res.appendContentString(");");
AjaxUtils.appendScriptFooter(res);
}
}
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxDefaultSubmitButton method appendToResponse.
@Override
public void appendToResponse(WOResponse response, WOContext context) {
WOComponent component = context.component();
String formName = (String) valueForBinding("formName", component);
String formReference = "this.form";
if (formName != null) {
formReference = "document." + formName;
}
StringBuilder onClickBuffer = new StringBuilder();
String onClickBefore = (String) valueForBinding("onClickBefore", component);
if (onClickBefore != null) {
onClickBuffer.append("if (");
onClickBuffer.append(onClickBefore);
onClickBuffer.append(") {");
}
// PROTOTYPE EFFECTS
String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
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() {");
}
if (updateContainerID != null) {
onClickBuffer.append("ASB.update('" + updateContainerID + "',");
} else {
onClickBuffer.append("ASB.request(");
}
onClickBuffer.append(formReference);
onClickBuffer.append(",null,");
NSMutableDictionary options = createAjaxOptions(component);
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;
}
}
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('}');
}
onClickBuffer.append("; return false;");
response.appendContentString("<input ");
appendTagAttributeToResponse(response, "tabindex", "");
appendTagAttributeToResponse(response, "type", "submit");
String name = nameInContext(context, component);
appendTagAttributeToResponse(response, "name", name);
appendTagAttributeToResponse(response, "value", valueForBinding("value", component));
appendTagAttributeToResponse(response, "accesskey", valueForBinding("accesskey", component));
// Suppress modal box focus ring if used inside of modal dialog
if (AjaxModalDialog.isInDialog(context)) {
StringBuilder sb = new StringBuilder("MB_notFocusable ");
Object cssClass = valueForBinding("class", component);
if (cssClass != null) {
sb.append(cssClass);
}
appendTagAttributeToResponse(response, "class", sb.toString());
} else {
appendTagAttributeToResponse(response, "class", valueForBinding("class", component));
}
appendTagAttributeToResponse(response, "style", "position:absolute;left:-10000px");
appendTagAttributeToResponse(response, "id", valueForBinding("id", component));
appendTagAttributeToResponse(response, "onclick", onClickBuffer.toString());
response.appendContentString(" />");
// fix for IE < 9 that deactivates the standard submit routine of the form and
// triggers the onClick handler of this submit element instead if the return key
// is pressed within a textfield, radiobutton, checkbox or select
ERXBrowser browser = ERXBrowserFactory.factory().browserMatchingRequest(context.request());
if (browser.isIE() && browser.majorVersion().compareTo(Integer.valueOf(9)) < 0) {
if (!hasBinding("formName")) {
formName = ERXWOForm.formName(context, "");
}
AjaxUtils.appendScriptHeader(response);
response.appendContentString("\nEvent.observe(document." + formName + ", 'keypress', function(e){");
// return key
response.appendContentString("if(e.keyCode==13){");
response.appendContentString("var shouldFire=false;var t=e.target;var tn=t.tagName.toLowerCase();");
response.appendContentString("if(tn==='select'){shouldFire=true;}");
response.appendContentString("else if(tn==='input'){var ty=t.type.toLowerCase();");
response.appendContentString("if(ty==='text' || ty==='radio' || ty==='checkbox'){shouldFire=true;}}");
response.appendContentString("if(shouldFire){$$('[name=" + name + "]')[0].fireEvent('onClick');e.returnValue=false;}");
response.appendContentString("}});");
AjaxUtils.appendScriptFooter(response);
}
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxDroppable method onDrop.
public String onDrop() {
boolean submit = ERXComponentUtilities.booleanValueForBinding(this, "submit", false);
String contextID = AjaxUtils.quote(context().contextID());
String elementID = AjaxUtils.quote(_elementID);
String droppableElementID = AjaxUtils.quote((String) valueForBinding("id"));
String draggableKeyName = AjaxUtils.quote(_draggableIDKeyName);
String updateContainerID = AjaxUtils.quote((String) valueForBinding("updateContainerID"));
String actionUrl = (submit && updateContainerID == null) ? null : AjaxUtils.quote(_actionUrl);
String form = (String) valueForBinding("formName");
if (submit) {
if (form == null) {
form = ERXWOForm.formName(context(), null);
if (form == null) {
throw new IllegalArgumentException("If submit is true, you must provide either a formName or your containing form must have a name.");
}
}
form = "document." + form;
}
String onbeforedrop = (String) valueForBinding("onBeforeDrop");
String ondrop = (String) valueForBinding("onDrop");
NSMutableDictionary options = new NSMutableDictionary();
if (canGetValueForBinding("onComplete")) {
options.setObjectForKey(valueForBinding("onComplete"), "onComplete");
}
if (canGetValueForBinding("confirmMessage")) {
options.setObjectForKey(new AjaxValue(AjaxOption.STRING, valueForBinding("confirmMessage")).javascriptValue(), "confirmMessage");
}
if (submit) {
AjaxSubmitButton.fillInAjaxOptions(this, this, _elementID, options);
}
StringBuilder onDropBuffer = new StringBuilder();
onDropBuffer.append("ADP.droppedFunc(" + contextID + "," + elementID + "," + droppableElementID + "," + draggableKeyName + "," + updateContainerID + "," + actionUrl + "," + form + "," + onbeforedrop + "," + ondrop + ",");
AjaxOptions.appendToBuffer(options, onDropBuffer, context());
onDropBuffer.append(')');
return onDropBuffer.toString();
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXRequest method _cookieDictionary.
/**
* Parses all cookies one at a time catch parse exception which just discards
* that cookie and not all cookies. It uses java.net.HttpCookie as a parser.
* @return a dictionary of cookies, parsed one cookie at a time
*/
private NSDictionary _cookieDictionary() {
if (_cookieDictionary == null) {
NSMutableDictionary<String, NSArray<String>> cookieDictionary = new NSMutableDictionary<String, NSArray<String>>();
//
// from WORequest._cookieDescription()
String cookie = headerForKey("cookie");
if (cookie == null || cookie.length() == 0)
// IIS cookies use a different header
cookie = headerForKey("http_cookie");
if (cookie != null && cookie.length() > 0) {
String[] cookies = cookie.split(";");
for (int i = 0; i < cookies.length; i++) {
try {
//
// only parse one cookie at a time => get(0)
HttpCookie httpCookie = HttpCookie.parse(cookies[i]).get(0);
//
// Cookies with longer paths are listed before cookies with shorter paths:
// see https://stackoverflow.com/a/24214538
// Cookies with longer Patch are more specific than cookies with shorter path
// and should not be replaced by a less specific cookie
// If a cookie with Therfore we do not override cookies if there are already there!
String cookieName = httpCookie.getName();
String cookieValue = httpCookie.getValue();
log.debug("Cookie: '" + cookieName + "' = '" + cookieValue + "'");
NSArray<String> cookieValueArray = cookieDictionary.get(cookieName);
if (cookieValueArray == null) {
cookieValueArray = new NSArray<>();
}
cookieValueArray = cookieValueArray.arrayByAddingObject(cookieValue);
cookieDictionary.put(cookieName, cookieValueArray);
} catch (Throwable t) {
log.warn("Unable to parse cookie '" + cookies[i] + "' : " + t.getMessage());
}
}
}
_cookieDictionary = cookieDictionary.immutableClone();
}
return _cookieDictionary;
}
Aggregations