cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coli...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2 ScriptableWidget.java
Date Sat, 20 Mar 2004 19:19:49 GMT
coliver     2004/03/20 11:19:49

  Modified:    src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2
                        ScriptableWidget.java
  Log:
  Fix AggregateField initialization
  
  Revision  Changes    Path
  1.3       +32 -27    cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2/ScriptableWidget.java
  
  Index: ScriptableWidget.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2/ScriptableWidget.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ScriptableWidget.java	11 Mar 2004 02:56:32 -0000	1.2
  +++ ScriptableWidget.java	20 Mar 2004 19:19:49 -0000	1.3
  @@ -330,9 +330,40 @@
       }
   
       public void jsSet_value(Object value) throws JavaScriptException {
  +        if (delegate instanceof AggregateField) {
  +            AggregateField aggregateField = (AggregateField)delegate;
  +            if (value instanceof Scriptable) {
  +                Scriptable obj = (Scriptable)value;
  +                Object[] ids = obj.getIds();
  +                for (int i = 0; i < ids.length; i++) {
  +                    String id = String.valueOf(ids[i]);
  +                    Object val = getProperty(obj, id);
  +                    ScriptableWidget wid = wrap(aggregateField.getWidget(id));
  +                    if (wid == null) {
  +                        throw new JavaScriptException("No field \"" + id + "\" in widget
\"" + aggregateField.getId() + "\"");
  +                    }
  +                    if (wid.delegate instanceof Field || 
  +                        wid.delegate instanceof BooleanField ||
  +                        wid.delegate instanceof Output) {
  +                        if (val instanceof Scriptable) {
  +                            Scriptable s = (Scriptable)val;
  +                            if (s.has("value", s)) {
  +                                wid.jsSet_value(s.get("value", s));
  +                            }
  +                        }
  +                    } else {
  +                        wid.jsSet_value(val);
  +                    }
  +                }
  +                aggregateField.combineFields();
  +                return;
  +            }
  +            // fall through
  +        }
           if (delegate instanceof DataWidget) {
               value = unwrap(value);
               if (value != null) {
  +                // Coerce values
                   Datatype datatype = ((DataWidget)delegate).getDatatype();
                   Class typeClass = datatype.getTypeClass();
                   if (typeClass == String.class) {
  @@ -377,32 +408,6 @@
                       Object elemValue = getProperty(arr, i);
                       ScriptableWidget wid = wrap(repeater.getRow(i));
                       wid.jsSet_value(elemValue);
  -                }
  -            }
  -        } else if (delegate instanceof AggregateField) {
  -            AggregateField aggregateField = (AggregateField)delegate;
  -            if (value instanceof Scriptable) {
  -                Scriptable obj = (Scriptable)value;
  -                Object[] ids = obj.getIds();
  -                for (int i = 0; i < ids.length; i++) {
  -                    String id = String.valueOf(ids[i]);
  -                    Object val = getProperty(obj, id);
  -                    ScriptableWidget wid = wrap(aggregateField.getWidget(id));
  -                    if (wid == null) {
  -                        throw new JavaScriptException("No field \"" + id + "\" in widget
\"" + aggregateField.getId() + "\"");
  -                    }
  -                    if (wid.delegate instanceof Field || 
  -                        wid.delegate instanceof BooleanField ||
  -                        wid.delegate instanceof Output) {
  -                        if (val instanceof Scriptable) {
  -                            Scriptable s = (Scriptable)val;
  -                            if (s.has("value", s)) {
  -                                wid.jsSet_value(s.get("value", s));
  -                            }
  -                        }
  -                    } else {
  -                        wid.jsSet_value(val);
  -                    }
                   }
               }
           } else if (delegate instanceof Repeater.RepeaterRow) {
  
  
  

Mime
View raw message