use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class ERXComponentUtilities method _queryParameterAssociations.
public static NSMutableDictionary<String, WOAssociation> _queryParameterAssociations(NSDictionary<String, WOAssociation> associations, boolean removeQueryParameterAssociations) {
NSMutableDictionary<String, WOAssociation> mutableAssociations = null;
if (removeQueryParameterAssociations) {
mutableAssociations = (NSMutableDictionary) associations;
}
NSMutableDictionary<String, WOAssociation> queryParameterAssociations = new NSMutableDictionary<>();
Enumeration keyEnum = associations.keyEnumerator();
while (keyEnum.hasMoreElements()) {
String key = (String) keyEnum.nextElement();
if (key.startsWith("?")) {
WOAssociation association = (WOAssociation) associations.valueForKey(key);
if (mutableAssociations != null) {
mutableAssociations.removeObjectForKey(key);
}
queryParameterAssociations.setObjectForKey(association, key);
}
}
return queryParameterAssociations;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class WOHelperFunctionDeclarationParser method _associationWithKey.
public static WOAssociation _associationWithKey(String associationValue, NSDictionary quotedStrings) {
WOAssociation association = null;
if (associationValue != null && associationValue.startsWith("~")) {
int associationValueLength = associationValue.length();
StringBuilder value = new StringBuilder();
int lastIndex = 0;
int index = 0;
while ((index = associationValue.indexOf(WOHelperFunctionDeclarationParser.QUOTED_STRING_KEY, lastIndex)) != -1) {
value.append(associationValue.substring(lastIndex, index));
int wodpValueStartIndex = index + WOHelperFunctionDeclarationParser.QUOTED_STRING_KEY.length();
int wodpValueEndIndex = wodpValueStartIndex;
for (; wodpValueEndIndex < associationValueLength && Character.isDigit(associationValue.charAt(wodpValueEndIndex)); wodpValueEndIndex++) {
// do nothing
}
String wodpKey = WOHelperFunctionDeclarationParser.QUOTED_STRING_KEY + associationValue.substring(wodpValueStartIndex, wodpValueEndIndex);
String quotedString = (String) quotedStrings.objectForKey(wodpKey);
if (quotedString != null) {
quotedString = quotedString.replaceAll("\\\"", "\\\\\"");
value.append("\"");
value.append(quotedString);
value.append("\"");
}
lastIndex = wodpValueEndIndex;
}
value.append(associationValue.substring(lastIndex));
associationValue = value.toString();
association = WOHelperFunctionAssociation.associationWithValue(associationValue);
} else {
String quotedString = (String) quotedStrings.objectForKey(associationValue);
// MS: WO 5.4 converts \n to an actual newline. I don't know if WO 5.3 does, too, but let's go ahead and be compatible with them as long as nobody is yelling.
if (quotedString != null) {
int backslashIndex = quotedString.indexOf('\\');
if (backslashIndex != -1) {
StringBuilder sb = new StringBuilder(quotedString);
int length = sb.length();
for (int i = backslashIndex; i < length; i++) {
char ch = sb.charAt(i);
if (ch == '\\' && i < length) {
char nextCh = sb.charAt(i + 1);
if (nextCh == 'n') {
sb.replace(i, i + 2, "\n");
} else if (nextCh == 'r') {
sb.replace(i, i + 2, "\r");
} else if (nextCh == 't') {
sb.replace(i, i + 2, "\t");
} else {
sb.replace(i, i + 2, String.valueOf(nextCh));
}
length--;
}
}
quotedString = sb.toString();
}
association = WOHelperFunctionAssociation.associationWithValue(quotedString);
} else if (_NSStringUtilities.isNumber(associationValue)) {
Number number = null;
if (associationValue != null && associationValue.contains(".")) {
number = Double.valueOf(associationValue);
} else {
number = WOShared.unsignedIntNumber(Integer.parseInt(associationValue));
}
association = WOHelperFunctionAssociation.associationWithValue(number);
} else if ("true".equalsIgnoreCase(associationValue) || "yes".equalsIgnoreCase(associationValue)) {
association = WOConstantValueAssociation.TRUE;
} else if ("false".equalsIgnoreCase(associationValue) || "no".equalsIgnoreCase(associationValue) || "nil".equalsIgnoreCase(associationValue) || "null".equalsIgnoreCase(associationValue)) {
association = WOConstantValueAssociation.FALSE;
} else {
association = WOHelperFunctionAssociation.associationWithKeyPath(associationValue);
}
}
return association;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class WOHelperFunctionDeclarationParser method _associationsForDictionaryString.
private NSMutableDictionary _associationsForDictionaryString(String declarationHeader, String declarationBody) throws WOHelperFunctionDeclarationFormatException {
NSMutableDictionary associations = new NSMutableDictionary();
String trimmedDeclarationBody = declarationBody.trim();
if (!trimmedDeclarationBody.startsWith("{") && !trimmedDeclarationBody.endsWith("}")) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Internal inconsistency : invalid dictionary for declaration:\n" + declarationHeader + " " + declarationBody);
}
int declarationBodyLength = trimmedDeclarationBody.length();
if (declarationBodyLength <= 2) {
return associations;
}
trimmedDeclarationBody = trimmedDeclarationBody.substring(1, declarationBodyLength - 1).trim();
NSArray bindings = NSArray.componentsSeparatedByString(trimmedDeclarationBody, ";");
Enumeration bindingsEnum = bindings.objectEnumerator();
do {
if (!bindingsEnum.hasMoreElements()) {
break;
}
String binding = ((String) bindingsEnum.nextElement()).trim();
if (binding.length() != 0) {
int equalsIndex = binding.indexOf('=');
if (equalsIndex < 0) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Invalid line. No equal in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
}
String key = binding.substring(0, equalsIndex).trim();
if (key.length() == 0) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing binding in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
}
String value = binding.substring(equalsIndex + 1).trim();
if (value.length() == 0) {
throw new WOHelperFunctionDeclarationFormatException("<WOHelperFunctionDeclarationParser> Missing value in line:\n" + binding + "\nfor declaration:\n" + declarationHeader + " " + declarationBody);
}
WOAssociation association = WOHelperFunctionDeclarationParser._associationWithKey(value, _quotedStrings);
Object quotedString = _quotedStrings.objectForKey(key);
if (quotedString != null) {
associations.setObjectForKey(association, quotedString);
} else {
associations.setObjectForKey(association, key);
}
}
} while (true);
// }
return associations;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class AjaxModalContainer method handleRequest.
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
WOComponent component = context.component();
WOResponse response = null;
WOAssociation action = associations().objectForKey("action");
if (action != null) {
action.valueInComponent(component);
}
if (booleanValueForBinding("ajax", false, component) && hasChildrenElements()) {
response = AjaxUtils.createResponse(request, context);
AjaxUtils.setPageReplacementCacheKey(context, _containerID(context));
appendChildrenToResponse(response, context);
}
return response;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class AjaxToggleLink method _appendAttributesToResponse.
public static void _appendAttributesToResponse(WOResponse response, WOContext context, WOAssociation toggleIDAssociation, WOAssociation effectAssociation, WOAssociation durationAssociation) {
WOComponent component = context.component();
String effect = null;
if (effectAssociation != null) {
effect = (String) effectAssociation.valueInComponent(component);
}
if (effect == null) {
effect = "blind";
}
String toggleID = (String) toggleIDAssociation.valueInComponent(component);
// PROTOTYPE EFFECTS
response.appendContentString(" onclick = \"Effect.toggle($wi('");
response.appendContentString(toggleID);
response.appendContentString("'), '");
response.appendContentString(effect);
response.appendContentString("', ");
NSMutableDictionary<String, WOAssociation> options = new NSMutableDictionary<>();
if (durationAssociation != null) {
options.setObjectForKey(durationAssociation, "duration");
}
AjaxOptions.appendToResponse(options, response, context);
response.appendContentString(")\"");
}
Aggregations