use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class WOHelperFunctionParser method createDeclaration.
public static WODeclaration createDeclaration(String declarationName, String declarationType, NSMutableDictionary associations) {
WODeclaration declaration = new WODeclaration(declarationName, declarationType, associations);
if (WOHelperFunctionParser._debugSupport && associations != null && associations.objectForKey(WOHTMLAttribute.Debug) == null) {
// associations.setObjectForKey(new WOConstantValueAssociation(Boolean.TRUE), WOHTMLAttribute.Debug);
Enumeration associationsEnum = associations.keyEnumerator();
while (associationsEnum.hasMoreElements()) {
String bindingName = (String) associationsEnum.nextElement();
WOAssociation association = (WOAssociation) associations.objectForKey(bindingName);
association.setDebugEnabledForBinding(bindingName, declarationName, declarationType);
association._setDebuggingEnabled(false);
}
}
return declaration;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class WOHelperFunctionParser method parserHelperAssociation.
protected WOAssociation parserHelperAssociation(WOAssociation originalAssociation) {
WOAssociation association = originalAssociation;
String originalKeyPath = null;
if (association instanceof WOKeyValueAssociation) {
WOKeyValueAssociation kvAssociation = (WOKeyValueAssociation) association;
originalKeyPath = kvAssociation.keyPath();
}
if (originalKeyPath != null) {
int pipeIndex = originalKeyPath.indexOf('|');
if (pipeIndex != -1) {
String targetKeyPath = originalKeyPath.substring(0, pipeIndex).trim();
String frameworkName = WOHelperFunctionRegistry.APP_FRAMEWORK_NAME;
String helperFunctionName = originalKeyPath.substring(pipeIndex + 1).trim();
String otherParams = null;
int openParenIndex = helperFunctionName.indexOf('(');
if (openParenIndex != -1) {
int closeParenIndex = helperFunctionName.indexOf(')', openParenIndex + 1);
otherParams = helperFunctionName.substring(openParenIndex + 1, closeParenIndex);
helperFunctionName = helperFunctionName.substring(0, openParenIndex);
}
int helperFunctionDotIndex = helperFunctionName.indexOf('.');
if (helperFunctionDotIndex != -1) {
frameworkName = helperFunctionName.substring(0, helperFunctionDotIndex);
helperFunctionName = helperFunctionName.substring(helperFunctionDotIndex + 1);
}
StringBuilder newKeyPath = new StringBuilder();
newKeyPath.append('~');
newKeyPath.append("@" + WOHelperFunctionRegistry.class.getName() + "@registry()._helperInstanceForFrameworkNamed(#this, \"");
newKeyPath.append(helperFunctionName);
newKeyPath.append("\", \"");
newKeyPath.append(targetKeyPath);
newKeyPath.append("\", \"");
newKeyPath.append(frameworkName);
newKeyPath.append("\").");
newKeyPath.append(helperFunctionName);
newKeyPath.append('(');
newKeyPath.append(targetKeyPath);
if (otherParams != null) {
newKeyPath.append(',');
newKeyPath.append(otherParams);
}
newKeyPath.append(')');
log.debug("Converted {} into {}", originalKeyPath, newKeyPath);
association = new WOConstantValueAssociation(newKeyPath.toString());
}
}
return association;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class ERXComponentUtilities method bindingIsSettable.
/**
* Checks if the association for a binding with the given name can assign
* values at runtime.
*
* @param name binding name
* @param associations array of associations
* @return <code>true</code> if binding is settable
*/
public static boolean bindingIsSettable(String name, NSDictionary<String, WOAssociation> associations) {
boolean isSettable = false;
WOAssociation association = bindingNamed(name, associations);
if (association != null) {
isSettable = association.isValueSettable();
}
return isSettable;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class ERXComponentUtilities method _queryParametersInComponent.
public static NSMutableDictionary _queryParametersInComponent(NSMutableDictionary associations, WOComponent component) {
NSMutableDictionary queryParameters = new NSMutableDictionary();
Enumeration keyEnum = associations.keyEnumerator();
while (keyEnum.hasMoreElements()) {
String key = (String) keyEnum.nextElement();
WOAssociation association = (WOAssociation) associations.valueForKey(key);
Object associationValue = association.valueInComponent(component);
if (associationValue != null) {
queryParameters.setObjectForKey(associationValue, key.substring(1));
}
}
return queryParameters;
}
use of com.webobjects.appserver.WOAssociation in project wonder-slim by undur.
the class ERXComponentUtilities method appendHtmlAttributes.
/**
* Appends a dictionary of associations as HTML attributes.
*
* @param associations
* the associations dictionary
* @param excludeKeys
* the associations to ignore
* @param response
* the response to write to
* @param component
* the component to evaluate the associations within
*/
public static void appendHtmlAttributes(NSDictionary<String, WOAssociation> associations, NSArray<String> excludeKeys, WOResponse response, WOComponent component) {
if (excludeKeys == null) {
excludeKeys = NSArray.EmptyArray;
}
for (String key : associations.allKeys()) {
if (!excludeKeys.contains(key)) {
WOAssociation association = associations.objectForKey(key);
ERXComponentUtilities.appendHtmlAttribute(key, association, response, component);
}
}
}
Aggregations