Package er.extensions.components.javascript

Source Code of er.extensions.components.javascript.ERXJSVariables

package er.extensions.components.javascript;

import java.util.Enumeration;

import org.apache.log4j.Logger;

import com.webobjects.appserver.WOComponent;
import com.webobjects.appserver.WOContext;
import com.webobjects.foundation.NSDictionary;
import com.webobjects.foundation.NSMutableDictionary;

/**
* Class for Wonder Component ERXJSVariables.
*
* @binding sample sample binding explanation
*
* @author ak on Sat May 03 2003
*/
public class ERXJSVariables extends WOComponent {
  /**
   * Do I need to update serialVersionUID?
   * See section 5.6 <cite>Type Changes Affecting Serialization</cite> on page 51 of the
   * <a href="http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf">Java Object Serialization Spec</a>
   */
  private static final long serialVersionUID = 1L;


    /** logging support */
    private static final Logger log = Logger.getLogger(ERXJSVariables.class);

    public NSDictionary _arguments;
        protected String currentKey;

    /**
     * Public constructor
     * @param context the context
     */
    public ERXJSVariables(WOContext context) {
        super(context);
    }

    /** component does not synchronize it's variables */
    @Override
    public boolean synchronizesVariablesWithBindings() { return false; }

    public NSDictionary arguments() {
        if(_arguments == null) {
            Object o = valueForBinding("arguments");
            if(o != null)
                _arguments = ((NSDictionary)o).mutableClone();
            else
                _arguments = new NSMutableDictionary();
               
            for(Enumeration e = bindingKeys().objectEnumerator(); e.hasMoreElements();) {
                String s = (String)e.nextElement();
                if(s.indexOf("?") == 0) {
                    Object obj = valueForBinding(s);
                    if(obj != null)
                        ((NSMutableDictionary)_arguments).setObjectForKey(obj, s.substring(1));
                }
            }
        }
        return _arguments;
    }

    public String currentKey() {
        return currentKey;
    }
   
    public String currentValue() {
        Object s = arguments().valueForKeyPath(currentKey());
        s = s == null ? "null" : s;
        return s.toString();
    }
}
TOP

Related Classes of er.extensions.components.javascript.ERXJSVariables

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.