You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/06/26 11:14:33 UTC

cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel ExpressionContextImpl.java

bruno       2003/06/26 02:14:33

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/formmodel
                        ExpressionContextImpl.java
  Log:
  Added new constructor
  
  Revision  Changes    Path
  1.2       +16 -1     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/ExpressionContextImpl.java
  
  Index: ExpressionContextImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/ExpressionContextImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExpressionContextImpl.java	22 Apr 2003 12:04:19 -0000	1.1
  +++ ExpressionContextImpl.java	26 Jun 2003 09:14:33 -0000	1.2
  @@ -60,9 +60,20 @@
    */
   public class ExpressionContextImpl implements ExpressionContext {
       private Widget widget;
  +    private boolean referenceChildren;
   
       public ExpressionContextImpl(Widget widget) {
           this.widget = widget;
  +        this.referenceChildren = false;
  +    }
  +
  +    /**
  +     * @param referenceChildren if true, variables will be resolved among the children of the given
  +     * container widget, rather than among the siblings of the widget.
  +     */
  +    public ExpressionContextImpl(ContainerWidget widget, boolean referenceChildren) {
  +        this.widget = widget;
  +        this.referenceChildren = referenceChildren;
       }
   
       /**
  @@ -85,7 +96,11 @@
        */
       public Object resolveVariable(String name) {
           // TODO allow to access other widgets instead of only siblings (allow going up with ../ notation or something)
  -        Widget widget = this.widget.getParent().getWidget(name);
  +        Widget widget;
  +        if (!referenceChildren)
  +            widget = this.widget.getParent().getWidget(name);
  +        else
  +            widget = ((ContainerWidget)this.widget).getWidget(name);
           if (widget != null) {
               Object value = widget.getValue();