Search in sources :

Example 21 with WOAssociation

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;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) Enumeration(java.util.Enumeration) WODeclaration(com.webobjects.appserver._private.WODeclaration) WOHTMLCommentString(com.webobjects.appserver._private.WOHTMLCommentString)

Example 22 with WOAssociation

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;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) WOConstantValueAssociation(com.webobjects.appserver._private.WOConstantValueAssociation) WOKeyValueAssociation(com.webobjects.appserver._private.WOKeyValueAssociation) WOHTMLCommentString(com.webobjects.appserver._private.WOHTMLCommentString)

Example 23 with WOAssociation

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;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation)

Example 24 with WOAssociation

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;
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation) Enumeration(java.util.Enumeration) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 25 with WOAssociation

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);
        }
    }
}
Also used : WOAssociation(com.webobjects.appserver.WOAssociation)

Aggregations

WOAssociation (com.webobjects.appserver.WOAssociation)27 NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)10 Enumeration (java.util.Enumeration)10 WOHTMLCommentString (com.webobjects.appserver._private.WOHTMLCommentString)8 WOComponent (com.webobjects.appserver.WOComponent)4 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)4 NSDictionary (com.webobjects.foundation.NSDictionary)4 WOKeyValueAssociation (com.webobjects.appserver._private.WOKeyValueAssociation)3 NSArray (com.webobjects.foundation.NSArray)3 WODeclaration (com.webobjects.appserver._private.WODeclaration)2 WOResponse (com.webobjects.appserver.WOResponse)1 WOBindingNameAssociation (com.webobjects.appserver._private.WOBindingNameAssociation)1 ERXMutableURL (er.extensions.foundation.ERXMutableURL)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1