}
public void convertOgnlConstantAssociations(NSMutableDictionary associations) {
for (Enumeration e = associations.keyEnumerator(); e.hasMoreElements();) {
String name = (String) e.nextElement();
WOAssociation association = (WOAssociation) associations.objectForKey(name);
boolean isConstant = false;
String keyPath = null;
if (association instanceof WOConstantValueAssociation) {
WOConstantValueAssociation constantAssociation = (WOConstantValueAssociation) association;
// AK: this sucks, but there is no API to get at the value
Object value = constantAssociation.valueInComponent(null);
keyPath = value != null ? value.toString() : null;
isConstant = true;
}
else if (association instanceof WOKeyValueAssociation) {
keyPath = association.keyPath();
}
else if (association instanceof WOBindingNameAssociation) {
WOBindingNameAssociation b = (WOBindingNameAssociation) association;
// AK: strictly speaking, this is not correct, as we only get the first part of
// the path. But take a look at WOBindingNameAssociation for a bit of fun...
keyPath = "^" + b._parentBindingName;
}
if (keyPath != null) {
if (associationMappings.size() != 0) {
int index = name.indexOf(':');
if (index > 0) {
String prefix = name.substring(0, index);
if (prefix != null) {
Class c = (Class) associationMappings.get(prefix);
if (c != null) {
String postfix = name.substring(index + 1);
WOAssociation newAssociation = createAssociationForClass(c, keyPath, isConstant);
associations.removeObjectForKey(name);
associations.setObjectForKey(newAssociation, postfix);
}
}
}
}
if (isConstant && keyPath.startsWith(ognlBindingFlag())) {
String ognlExpression = keyPath.substring(ognlBindingFlag().length(), keyPath.length());
if (ognlExpression.length() > 0) {
WOAssociation newAssociation = new WOOgnlAssociation(ognlExpression);
NSArray keys = associations.allKeysForObject(association);
//if (log.isDebugEnabled())
// log.debug("Constructing Ognl association for binding key(s): "
// + (keys.count() == 1 ? keys.lastObject() : keys) + " expression: " + ognlExpression);
if (keys.count() == 1) {