mpo         2004/05/07 09:43:43

  Modified:    src/blocks/forms/java/org/apache/cocoon/forms/binding
                        JXPathBindingBase.java RepeaterJXPathBinding.java
               src/blocks/forms/java/org/apache/cocoon/forms/formmodel
                        Repeater.java WidgetDefinitionList.java
                        AbstractContainerWidget.java
                        DeleteRowsActionDefinition.java RepeaterAction.java
                        Form.java ExpressionContextImpl.java
                        AbstractWidget.java ContainerWidget.java Union.java
                        AggregateField.java Widget.java
               src/blocks/forms/java/org/apache/cocoon/forms/transformation
                        WidgetReplacingPipe.java
                        EffectWidgetReplacingPipe.java
               src/blocks/forms/java/org/apache/cocoon/forms/samples
                        InitForm1Action.java
               src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript
                        ScriptableWidget.java
               src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2
                        ScriptableWidget.java
               src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v3
                        ScriptableWidget.java
  Log:
  Introducing lookupWidget(path) as discussed in this thread: 
  http://marc.theaimsgroup.com/?t=108333621200001&r=1&w=2
  And renaming the get/has/addWIdget on Container to get/has/addChild to be 
more describing.
  Left TODO on possible removal of addChild method.
  Kept Repeater as not-containerwidget (since that part of the discussion 
remained somewhat inconclusive)
  This also pulls up the lookupWidget() method as the resolving method for the 
expression-context.
  (Q: aren't slashes awkward there?)
  
  Revision  Changes    Path
  1.5       +2 -4      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java
  
  Index: JXPathBindingBase.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/binding/JXPathBindingBase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JXPathBindingBase.java    7 May 2004 13:42:09 -0000       1.4
  +++ JXPathBindingBase.java    7 May 2004 16:43:42 -0000       1.5
  @@ -116,9 +116,7 @@
           
           Widget childWidget = null;
           
  -        if (parent instanceof ContainerWidget) {
  -           childWidget = ((ContainerWidget) parent).getWidget(id);
  -        }
  +        childWidget = parent.lookupWidget(id);
               
           if (childWidget == null) {
               throw new RuntimeException(getClass().getName() + ": Widget \"" +
  
  
  
  1.8       +2 -2      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java
  
  Index: RepeaterJXPathBinding.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RepeaterJXPathBinding.java        6 May 2004 14:59:44 -0000       1.7
  +++ RepeaterJXPathBinding.java        7 May 2004 16:43:42 -0000       1.8
  @@ -334,7 +334,7 @@
               int size = childBindings.length;
               for (int i = 0; i < size; i++) {
                   String fieldId = 
((ValueJXPathBinding)childBindings[i]).getFieldId();
  -                Widget widget = row.getWidget(fieldId);
  +                Widget widget = row.getChild(fieldId);
                   Object value = widget.getValue();
                   identity.add(value);
               }
  
  
  
  1.13      +20 -6     
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java
  
  Index: Repeater.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Repeater.java     7 May 2004 13:42:09 -0000       1.12
  +++ Repeater.java     7 May 2004 16:43:42 -0000       1.13
  @@ -61,10 +61,6 @@
           return rows.size();
       }
   
  -//    public void addWidget(Widget widget) {
  -//        throw new RuntimeException("Repeater.addWidget(): Please use 
addRow() instead.");
  -//    }
  -
       public RepeaterRow addRow() {
           RepeaterRow repeaterRow = new RepeaterRow(definition);
           rows.add(repeaterRow);
  @@ -86,6 +82,24 @@
       }
       
       /**
  +     * Overrides [EMAIL PROTECTED] AbstractWidget#getChild(String)} to 
return the 
  +     * repeater-row indicated by the index in 'id'
  +     * 
  +     * @param id index of the row as a string-id
  +     * @return the repeater-row at the specified index
  +     */
  +    public Widget getChild(String id) {
  +        int rowIndex = -1;
  +        try {
  +             rowIndex = Integer.parseInt(id);
  +        } catch (NumberFormatException nfe) {
  +        }
  +        if (rowIndex < 0 && rowIndex > getSize()) 
  +            return null;
  +        return getRow(rowIndex);
  +    }
  +    
  +    /**
        * Crawls up the parents of a widget up to finding a repeater row.
        * 
        * @param widget the widget whose row is to be found
  @@ -161,7 +175,7 @@
        */
       public Widget getWidget(int rowIndex, String id) {
           RepeaterRow row = (RepeaterRow)rows.get(rowIndex);
  -        return row.getWidget(id);
  +        return row.getChild(id);
       }
   //
   //    public boolean hasWidget(String id) {
  
  
  
  1.2       +3 -3      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
  
  Index: WidgetDefinitionList.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WidgetDefinitionList.java 21 Apr 2004 20:30:49 -0000      1.1
  +++ WidgetDefinitionList.java 7 May 2004 16:43:42 -0000       1.2
  @@ -129,7 +129,7 @@
           }
           Widget widget = widgetDefinition.createInstance();
           if (widget != null)
  -            ((ContainerWidget)parent).addWidget(widget);
  +            ((ContainerWidget)parent).addChild(widget);
       }
   
       public void createWidgets(Widget parent) {
  @@ -138,7 +138,7 @@
               WidgetDefinition widgetDefinition = 
(WidgetDefinition)definitionsIt.next();
               Widget widget = widgetDefinition.createInstance();
               if (widget != null)
  -                ((ContainerWidget)parent).addWidget(widget);
  +                ((ContainerWidget)parent).addChild(widget);
           }
       }
   }
  
  
  
  1.12      +6 -6      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java
  
  Index: AbstractContainerWidget.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AbstractContainerWidget.java      1 May 2004 00:05:44 -0000       1.11
  +++ AbstractContainerWidget.java      7 May 2004 16:43:42 -0000       1.12
  @@ -41,19 +41,19 @@
           widgets = new WidgetList();
       }
   
  -    public void addWidget(Widget widget) {
  +    public void addChild(Widget widget) {
           widget.setParent(this);
           widgets.addWidget(widget);
       }
   
  -    public boolean hasWidget(String id) {
  +    public boolean hasChild(String id) {
           return widgets.hasWidget(id);
       }
   
  -    public Widget getWidget(String id) {
  -     return widgets.getWidget(id);
  +    public Widget getChild(String id) {
  +        return widgets.getWidget(id);
       }
  -
  +    
       public Iterator getChildren() {
           return widgets.iterator();
       }
  
  
  
  1.2       +2 -2      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/DeleteRowsActionDefinition.java
  
  Index: DeleteRowsActionDefinition.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/DeleteRowsActionDefinition.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeleteRowsActionDefinition.java   9 Mar 2004 10:33:50 -0000       1.1
  +++ DeleteRowsActionDefinition.java   7 May 2004 16:43:42 -0000       1.2
  @@ -37,7 +37,7 @@
                   Repeater repeater = 
((RepeaterAction)event.getSource()).getRepeater();
                   for (int i = repeater.getSize() - 1; i >= 0; i--) {
                       Repeater.RepeaterRow row = repeater.getRow(i);
  -                    if 
(Boolean.TRUE.equals(row.getWidget(DeleteRowsActionDefinition.this.selectName).getValue()))
 {
  +                    if 
(Boolean.TRUE.equals(row.getChild(DeleteRowsActionDefinition.this.selectName).getValue()))
 {
                           repeater.removeRow(i);
                       }
                   }
  
  
  
  1.4       +2 -2      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterAction.java
  
  Index: RepeaterAction.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RepeaterAction.java       23 Apr 2004 13:02:31 -0000      1.3
  +++ RepeaterAction.java       7 May 2004 16:43:42 -0000       1.4
  @@ -40,7 +40,7 @@
               Widget widget;
               if (name != null) {
                   // Get the corresponding sibling
  -                widget = ((ContainerWidget)getParent()).getWidget(name);
  +                widget = ((ContainerWidget)getParent()).getChild(name);
               } else {
                   // Get the grand-parent (parent is the repeater row).
                   widget = getParent().getParent();
  
  
  
  1.15      +2 -2      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Form.java
  
  Index: Form.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Form.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Form.java 1 May 2004 00:05:44 -0000       1.14
  +++ Form.java 7 May 2004 16:43:42 -0000       1.15
  @@ -207,7 +207,7 @@
               StringTokenizer stok = new StringTokenizer(submitId, ".");
               Widget submit = this;
               while (stok.hasMoreTokens()) {
  -                submit = 
((ContainerWidget)submit).getWidget(stok.nextToken());
  +                submit = submit.lookupWidget(stok.nextToken());
                   if (submit == null) {
                       throw new IllegalArgumentException("Invalid submit id 
(no such widget): " + submitId);
                   }
  
  
  
  1.3       +3 -3      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ExpressionContextImpl.java
  
  Index: ExpressionContextImpl.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ExpressionContextImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExpressionContextImpl.java        23 Apr 2004 13:02:31 -0000      1.2
  +++ ExpressionContextImpl.java        7 May 2004 16:43:42 -0000       1.3
  @@ -65,9 +65,9 @@
           // TODO allow to access other widgets instead of only siblings 
(allow going up with ../ notation or something)
           Widget widget;
           if (!referenceChildren)
  -            widget = 
((ContainerWidget)this.widget.getParent()).getWidget(name);
  +            widget = 
((ContainerWidget)this.widget.getParent()).lookupWidget(name);
           else
  -            widget = ((ContainerWidget)this.widget).getWidget(name);
  +            widget = ((ContainerWidget)this.widget).lookupWidget(name);
           if (widget != null) {
               Object value = widget.getValue();
   
  
  
  
  1.18      +45 -13    
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
  
  Index: AbstractWidget.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AbstractWidget.java       7 May 2004 13:42:09 -0000       1.17
  +++ AbstractWidget.java       7 May 2004 16:43:42 -0000       1.18
  @@ -123,18 +123,6 @@
           return this.form;
       }
   
  -    
  -    //TODO: check why this namespace property exists, it seems to be 
  -    // deceptively resemblant to the getFullyQualifiedId, 
  -    // looks like it can be removed, no?
  -//    public String getNamespace() {    
  -//        if (getParent() != null && getParent().getNamespace().length() > 
0) {
  -//            return getParent().getNamespace() + "." + getId();
  -//        } else {
  -//            return getId();
  -//        }
  -//    }
  -
       public String getRequestParameterName() {
           Widget myParent = getParent();
           if (myParent != null) {
  @@ -147,6 +135,50 @@
           return getId();
       }
   
  +     public Widget lookupWidget(String path) {
  +        
  +        if (path == null && path.equals(""))
  +            return this;
  +        
  +        Widget relativeWidget;
  +        String relativePath = null;        
  +        int sepPosition = path.indexOf("" + Widget.PATH_SEPARATOR);
  +
  +        if (sepPosition < 0) {
  +            //last step
  +            if (path.startsWith("..")) return getParent();
  +            return getChild(path);
  +        } else if (sepPosition == 0) {
  +            //absolute path
  +                     relativeWidget = getForm();
  +            relativePath = path.substring(1);
  +        } else {
  +             if (path.startsWith(".." + Widget.PATH_SEPARATOR))  {
  +                     relativeWidget = getParent();
  +                relativePath = path.substring(3);
  +            } else {
  +                String childId = path.substring(0, sepPosition );
  +                relativeWidget = getChild(childId);            
  +                relativePath = path.substring(sepPosition+1);
  +            }
  +        }
  +        
  +        if (relativeWidget == null) return null;
  +        return relativeWidget.lookupWidget(relativePath);
  +     }
  +    
  +    /**
  +     * 
  +     * Concrete widgets that contain actual child widgets should override to 
  +     * return the actual child-widget.
  +     * 
  +     * @param id of the child-widget
  +     * @returns <code>null</code> if not overriden.
  +     */
  +    protected Widget getChild(String id) {
  +     return null;
  +    }
  +    
       public Object getValue() {
           return null;
       }
  
  
  
  1.5       +6 -4      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ContainerWidget.java
  
  Index: ContainerWidget.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ContainerWidget.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContainerWidget.java      23 Apr 2004 23:34:56 -0000      1.4
  +++ ContainerWidget.java      7 May 2004 16:43:42 -0000       1.5
  @@ -29,18 +29,20 @@
       /**
        * Adds a child widget.
        */
  -    public void addWidget(Widget widget);
  +    public void addChild(Widget widget);
  +    //TODO: check to remove since we have no removeChild
  +    
   
       /**
        * Checks if there is a child widget with the given id.
        */
  -    public boolean hasWidget(String id);
  +    public boolean hasChild(String id);
   
       /**
        * Gets the child widget with the given id.
        * @return null if there is no child with the given id.
        */
  -    public Widget getWidget(String id);
  +    public Widget getChild(String id);
   
       /**
        * @return an iterator over the widgets this object contains
  
  
  
  1.11      +6 -6      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java
  
  Index: Union.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Union.java        30 Apr 2004 12:19:01 -0000      1.10
  +++ Union.java        7 May 2004 16:43:43 -0000       1.11
  @@ -58,7 +58,7 @@
       // *widget* (not definition) references after the expansion has put all 
of the widgets in place.
       public void resolve() {
           String caseWidgetId = definition.getCaseWidgetId();
  -        caseWidget = ((ContainerWidget)getParent()).getWidget(caseWidgetId);
  +        caseWidget = ((ContainerWidget)getParent()).getChild(caseWidgetId);
       }
   
       /**
  @@ -80,7 +80,7 @@
           // Read current case from request
           String value = (String)getValue();
           if (value != null && !value.equals(""))
  -            if ((widget = getWidget(value)) != null)
  +            if ((widget = getChild(value)) != null)
                   widget.readFromRequest(formContext);
   
           // Read union discriminant value from request
  @@ -94,15 +94,15 @@
           // Read current case from request
           String value = (String)getValue();
           if (value != null && !value.equals(""))
  -            if ((widget = getWidget(value)) != null)
  +            if ((widget = getChild(value)) != null)
                   valid = valid & widget.validate();
           return valid;
       }
   
  -    public Widget getWidget(String id) {
  +    public Widget getChild(String id) {
           if (!widgets.hasWidget(id) && 
((ContainerDefinition)definition).hasWidget(id))
               ((ContainerDefinition)definition).createWidget(this, id);
  -        return super.getWidget(id);
  +        return super.getChild(id);
       }
   
       
  
  
  
  1.10      +4 -4      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
  
  Index: AggregateField.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AggregateField.java       7 May 2004 13:42:10 -0000       1.9
  +++ AggregateField.java       7 May 2004 16:43:43 -0000       1.10
  @@ -72,7 +72,7 @@
           return (AggregateFieldDefinition)getDefinition();
       }
   
  -    public void addWidget(Widget widget) {
  +    public void addChild(Widget widget) {
        if (!(widget instanceof Field)) 
               throw new IllegalArgumentException("AggregateField can only 
contain fields.");
           addField((Field)widget);
  @@ -85,7 +85,7 @@
       }
   
   
  -    public boolean hasWidget(String id) {
  +    public boolean hasChild(String id) {
           return this.fieldsById.containsKey(id);
       }
   
  @@ -218,7 +218,7 @@
           return AGGREGATEFIELD_EL;
       }
         
  -    public Widget getWidget(String id) {
  +    public Widget getChild(String id) {
           return (Widget)fieldsById.get(id);
       }
   }
  
  
  
  1.13      +16 -1     
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java
  
  Index: Widget.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Widget.java       7 May 2004 13:42:10 -0000       1.12
  +++ Widget.java       7 May 2004 16:43:43 -0000       1.13
  @@ -52,6 +52,12 @@
    * @version CVS $Id$
    */
   public interface Widget {
  +    
  +    /**
  +     * Widget-Separator used in path-like notations
  +     * @see #lookupWidget(String)
  +     */
  +    public static final char PATH_SEPARATOR = '/';
   
       /**
        * @return  the source location of this widget.
  @@ -89,6 +95,15 @@
        */
       public String getRequestParameterName();
   
  +    /**
  +     * Finds a widget relative to this one based on a path-like
  +     * string (/-delimted) into the widget-tree structure.
  +     * This supports '../' and '/' to point to  
  +     * @return the found widget or <code>null</code> if allong the traversal
  +     *   of the path an invalid section was encountered. 
  +     */
  +    public Widget lookupWidget(String path);
  +    
       /**
        * Lets this widget read its data from a request. At this point the 
Widget
        * may try to convert the request parameter to its native datatype (if it
  
  
  
  1.8       +2 -2      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/transformation/WidgetReplacingPipe.java
  
  Index: WidgetReplacingPipe.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/transformation/WidgetReplacingPipe.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WidgetReplacingPipe.java  7 May 2004 13:42:10 -0000       1.7
  +++ WidgetReplacingPipe.java  7 May 2004 16:43:43 -0000       1.8
  @@ -250,7 +250,7 @@
           if (widgetId == null || widgetId.equals("")) {
               throw new SAXException("FormsTemplateTransformer: missing id 
attribute on a Cocoon Forms element.");
           }
  -        Widget widget = ((ContainerWidget)contextWidget).getWidget(widgetId);
  +        Widget widget = ((ContainerWidget)contextWidget).getChild(widgetId);
           if (widget == null) {
               throw new SAXException("FormsTemplateTransformer: widget with id 
\"" + widgetId + "\" does not exist in the container " + 
contextWidget.getRequestParameterName());
           }
  
  
  
  1.13      +2 -2      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java
  
  Index: EffectWidgetReplacingPipe.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/transformation/EffectWidgetReplacingPipe.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- EffectWidgetReplacingPipe.java    7 May 2004 13:42:10 -0000       1.12
  +++ EffectWidgetReplacingPipe.java    7 May 2004 16:43:43 -0000       1.13
  @@ -168,7 +168,7 @@
       }
   
       protected Widget getWidget(String widgetId) throws SAXException {
  -        Widget widget = ((ContainerWidget)contextWidget).getWidget(widgetId);
  +        Widget widget = ((ContainerWidget)contextWidget).getChild(widgetId);
           if (widget == null) {
               if (contextWidget.getRequestParameterName().equals("")) {
                   throwSAXException("Widget with id \"" + widgetId + "\" does 
not exist in the form container.");
  
  
  
  1.4       +3 -3      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/samples/InitForm1Action.java
  
  Index: InitForm1Action.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/samples/InitForm1Action.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InitForm1Action.java      18 Mar 2004 21:04:40 -0000      1.3
  +++ InitForm1Action.java      7 May 2004 16:43:43 -0000       1.4
  @@ -44,10 +44,10 @@
   
           Form form = formManager.createForm(resolver.resolveURI(formSource));
   
  -        Field birthDate = (Field)form.getWidget("birthdate");
  +        Field birthDate = (Field)form.getChild("birthdate");
           birthDate.setValue(new Date());
   
  -        Repeater repeater = (Repeater)form.getWidget("contacts");
  +        Repeater repeater = (Repeater)form.getChild("contacts");
           repeater.addRow();
           Field field = (Field)repeater.getWidget(0, "firstname");
           field.setValue("Jules");
  
  
  
  1.4       +4 -4      
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ScriptableWidget.java
  
  Index: ScriptableWidget.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ScriptableWidget.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ScriptableWidget.java     23 Apr 2004 13:02:31 -0000      1.3
  +++ ScriptableWidget.java     7 May 2004 16:43:43 -0000       1.4
  @@ -76,7 +76,7 @@
                   return true;
               }
           } else if (delegate != null) {
  -            Widget sub = ((ContainerWidget)delegate).getWidget(id);
  +            Widget sub = delegate.lookupWidget(id);
               if (sub != null) {
                   return true;
               }
  @@ -108,7 +108,7 @@
                   return new Integer(values.length);
               }
           } else if (delegate != null) {
  -            Widget sub = ((ContainerWidget)delegate).getWidget(id);
  +            Widget sub = delegate.lookupWidget(id);
               if (sub != null) {
                   if (sub instanceof Field ||
                       sub instanceof BooleanField ||
  @@ -191,7 +191,7 @@
                   }
               }
           } else if (delegate != null) {
  -            Widget sub = ((ContainerWidget)delegate).getWidget(id);
  +            Widget sub = delegate.lookupWidget(id);
               if (sub instanceof Field) {
                   Field field = (Field)sub;
                   value = unwrap(value);
  
  
  
  1.10      +10 -13    
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ScriptableWidget.java     7 May 2004 13:42:11 -0000       1.9
  +++ ScriptableWidget.java     7 May 2004 16:43:43 -0000       1.10
  @@ -128,11 +128,9 @@
   
       public boolean has(String id, Scriptable start) {
           if (delegate != null) {
  -            if (delegate instanceof ContainerWidget) {
  -                Widget sub = ((ContainerWidget)delegate).getWidget(id);
  -                if (sub != null) {
  -                    return true;
  -                }
  +            Widget sub = delegate.lookupWidget(id);
  +            if (sub != null) {
  +                return true;
               }
           } 
           return super.has(id, start);
  @@ -158,8 +156,8 @@
           if (result != NOT_FOUND) {
               return result;
           }
  -        if (delegate != null && delegate instanceof ContainerWidget) {
  -            Widget sub = ((ContainerWidget)delegate).getWidget(id);
  +        if (delegate != null ) {
  +            Widget sub = delegate.lookupWidget(id);
               if (sub != null) {
                   return wrap(sub);
               }
  @@ -338,7 +336,7 @@
                   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));
  +                    ScriptableWidget wid = wrap(aggregateField.getChild(id));
                       if (wid == null) {
                           throw new JavaScriptException("No field \"" + id + 
"\" in widget \"" + aggregateField.getId() + "\"");
                       }
  @@ -418,7 +416,7 @@
                   for (int i = 0; i < ids.length; i++) {
                       String id = String.valueOf(ids[i]);
                       Object val = getProperty(obj, id);
  -                    ScriptableWidget wid = wrap(row.getWidget(id));
  +                    ScriptableWidget wid = wrap(row.getChild(id));
                       if (wid == null) {
                           throw new JavaScriptException("No field \"" + id + 
"\" in row " + i + " of repeater \"" + row.getParent().getId() + "\"");
                       }
  @@ -498,10 +496,9 @@
           return false;
       }
   
  -    public ScriptableWidget jsFunction_getWidget(String id) {
  +    public ScriptableWidget jsFunction_lookupWidget(String id) {
           Widget sub = null;
  -        if (delegate instanceof ContainerWidget)
  -            sub = ((ContainerWidget)delegate).getWidget(id);
  +        sub = delegate.lookupWidget(id);
           return wrap(sub);
       }
   
  
  
  
  1.3       +10 -13    
cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v3/ScriptableWidget.java
  
  Index: ScriptableWidget.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v3/ScriptableWidget.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ScriptableWidget.java     7 May 2004 13:42:11 -0000       1.2
  +++ ScriptableWidget.java     7 May 2004 16:43:43 -0000       1.3
  @@ -119,11 +119,9 @@
   
       public boolean has(String id, Scriptable start) {
           if (delegate != null) {
  -            if (delegate instanceof ContainerWidget) {
  -                Widget sub = ((ContainerWidget)delegate).getWidget(id);
  -                if (sub != null) {
  -                    return true;
  -                }
  +            Widget sub = delegate.lookupWidget(id);
  +            if (sub != null) {
  +                return true;
               }
           } 
           return super.has(id, start);
  @@ -149,8 +147,8 @@
           if (result != NOT_FOUND) {
               return result;
           }
  -        if (delegate != null && delegate instanceof ContainerWidget) {
  -            Widget sub = ((ContainerWidget)delegate).getWidget(id);
  +        if (delegate != null) {
  +            Widget sub = delegate.lookupWidget(id);
               if (sub != null) {
                   return wrap(sub);
               }
  @@ -329,7 +327,7 @@
                   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));
  +                    ScriptableWidget wid = wrap(aggregateField.getChild(id));
                       if (wid == null) {
                           throw new JavaScriptException("No field \"" + id + 
"\" in widget \"" + aggregateField.getId() + "\"");
                       }
  @@ -409,7 +407,7 @@
                   for (int i = 0; i < ids.length; i++) {
                       String id = String.valueOf(ids[i]);
                       Object val = getProperty(obj, id);
  -                    ScriptableWidget wid = wrap(row.getWidget(id));
  +                    ScriptableWidget wid = wrap(row.getChild(id));
                       if (wid == null) {
                           throw new JavaScriptException("No field \"" + id + 
"\" in row " + i + " of repeater \"" + row.getParent().getId() + "\"");
                       }
  @@ -489,10 +487,9 @@
           return false;
       }
   
  -    public ScriptableWidget jsFunction_getWidget(String id) {
  +    public ScriptableWidget jsFunction_lookupWidget(String id) {
           Widget sub = null;
  -        if (delegate instanceof ContainerWidget)
  -            sub = ((ContainerWidget)delegate).getWidget(id);
  +        sub = delegate.lookupWidget(id);
           return wrap(sub);
       }
   
  
  
  

Reply via email to