cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation WidgetReplacingPipe.java
Date Mon, 28 Jul 2003 15:57:16 GMT
bruno       2003/07/28 08:57:16

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/datatype
                        Datatype.java
               src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl
                        AbstractDatatype.java AbstractDatatypeBuilder.java
                        DateTypeBuilder.java DecimalTypeBuilder.java
                        LongTypeBuilder.java StringTypeBuilder.java
               src/blocks/woody/java/org/apache/cocoon/woody/formmodel
                        Field.java FieldDefinition.java
                        FieldDefinitionBuilder.java MultiValueField.java
                        MultiValueFieldDefinitionBuilder.java
               src/blocks/woody/java/org/apache/cocoon/woody/transformation
                        WidgetReplacingPipe.java
  Added:       src/blocks/woody/java/org/apache/cocoon/woody/formmodel
                        AbstractDatatypeWidgetDefinition.java
                        AbstractDatatypeWidgetDefinitionBuilder.java
  Log:
  Made selection lists a property of a widget rather than the datatype.
  
  Revision  Changes    Path
  1.3       +0 -5      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/Datatype.java
  
  Index: Datatype.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/Datatype.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Datatype.java	15 Jul 2003 14:09:25 -0000	1.2
  +++ Datatype.java	28 Jul 2003 15:57:15 -0000	1.3
  @@ -108,11 +108,6 @@
       public String getDescriptiveName();
   
       /**
  -     * Returns the selection list associated with this datatype, or null if it has none.
  -     */
  -    public SelectionList getSelectionList();
  -
  -    /**
        * Indicates wether this datatype represents an array type. This approach has been
        * chosen instead of creating a seperate ArrayDatatype interface (and corresponding
        * implementations), since almost all functionality is the same between the scalar
  
  
  
  1.4       +0 -11     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/AbstractDatatype.java
  
  Index: AbstractDatatype.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/AbstractDatatype.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractDatatype.java	15 Jul 2003 14:09:25 -0000	1.3
  +++ AbstractDatatype.java	28 Jul 2003 15:57:15 -0000	1.4
  @@ -62,7 +62,6 @@
    */
   public abstract class AbstractDatatype implements Datatype {
       private List validationRules = new ArrayList();
  -    private SelectionList selectionList;
       private boolean arrayType = false;
       private DatatypeBuilder builder;
       private Convertor convertor;
  @@ -80,16 +79,6 @@
   
       public void addValidationRule(ValidationRule validationRule) {
           validationRules.add(validationRule);
  -    }
  -
  -    public void setSelectionList(SelectionList selectionList) {
  -        if (selectionList.getDatatype() != this)
  -            throw new RuntimeException("Error in AbstractDatatype.setSelectionList: tried
to assign a SelectionList that is not associated with this datatype.");
  -        this.selectionList = selectionList;
  -    }
  -
  -    public SelectionList getSelectionList() {
  -        return selectionList;
       }
   
       public boolean isArrayType() {
  
  
  
  1.7       +0 -46     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/AbstractDatatypeBuilder.java
  
  Index: AbstractDatatypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/AbstractDatatypeBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractDatatypeBuilder.java	16 Jul 2003 13:59:18 -0000	1.6
  +++ AbstractDatatypeBuilder.java	28 Jul 2003 15:57:15 -0000	1.7
  @@ -65,9 +65,6 @@
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceResolver;
   import org.w3c.dom.Element;
  -import org.w3c.dom.Document;
  -import org.xml.sax.InputSource;
  -
   import java.io.IOException;
   
   /**
  @@ -124,49 +121,6 @@
   
       public Convertor getPlainConvertor() {
           return plainConvertor;
  -    }
  -
  -    protected Source resolve(String src) throws IOException, ServiceException {
  -        SourceResolver resolver = null;
  -        try {
  -            resolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
  -            return resolver.resolveURI(src);
  -        } finally {
  -            if (resolver != null)
  -                serviceManager.release(resolver);
  -        }
  -    }
  -
  -    protected void buildSelectionList(Element datatypeElement, AbstractDatatype datatype)
throws Exception {
  -        Element selectionListElement = DomHelper.getChildElement(datatypeElement, Constants.WD_NS,
"selection-list");
  -        if (selectionListElement != null) {
  -            SelectionList selectionList;
  -            String src = selectionListElement.getAttribute("src");
  -            if (src.length() > 0) {
  -                boolean dynamic = DomHelper.getAttributeAsBoolean(selectionListElement,
"dynamic", false);
  -                if (!dynamic) {
  -                    selectionListElement = readSelectionList(src);
  -                    selectionList = SelectionListBuilder.build(selectionListElement, datatype);
  -                } else {
  -                    selectionList = new DynamicSelectionList(datatype, src, serviceManager);
  -                }
  -            } else {
  -                // selection list is defined inline
  -                selectionList = SelectionListBuilder.build(selectionListElement, datatype);
  -            }
  -            datatype.setSelectionList(selectionList);
  -        }
  -    }
  -
  -    private Element readSelectionList(String src) throws Exception {
  -        Source source = resolve(src);
  -        InputSource inputSource = new InputSource(source.getInputStream());
  -        inputSource.setSystemId(source.getURI());
  -        Document document = DomHelper.parse(inputSource);
  -        Element selectionListElement = document.getDocumentElement();
  -        if (!Constants.WD_NS.equals(selectionListElement.getNamespaceURI()) || !"selection-list".equals(selectionListElement.getLocalName()))
  -            throw new Exception("Excepted a wd:selection-list element at " + DomHelper.getLocation(selectionListElement));
  -        return selectionListElement;
       }
   
       protected void buildValidationRules(Element datatypeElement, AbstractDatatype datatype,
DatatypeManager datatypeManager) throws Exception {
  
  
  
  1.2       +0 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/DateTypeBuilder.java
  
  Index: DateTypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/DateTypeBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DateTypeBuilder.java	15 Jul 2003 14:06:16 -0000	1.1
  +++ DateTypeBuilder.java	28 Jul 2003 15:57:15 -0000	1.2
  @@ -65,7 +65,6 @@
   
           buildValidationRules(datatypeElement, type, datatypeManager);
           buildConvertor(datatypeElement, type);
  -        buildSelectionList(datatypeElement, type);
   
           return type;
       }
  
  
  
  1.2       +0 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/DecimalTypeBuilder.java
  
  Index: DecimalTypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/DecimalTypeBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DecimalTypeBuilder.java	25 Jul 2003 16:21:31 -0000	1.1
  +++ DecimalTypeBuilder.java	28 Jul 2003 15:57:15 -0000	1.2
  @@ -65,7 +65,6 @@
   
           buildValidationRules(datatypeElement, type, datatypeManager);
           buildConvertor(datatypeElement, type);
  -        buildSelectionList(datatypeElement, type);
   
           return type;
       }
  
  
  
  1.3       +0 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/LongTypeBuilder.java
  
  Index: LongTypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/LongTypeBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LongTypeBuilder.java	15 Jul 2003 14:09:25 -0000	1.2
  +++ LongTypeBuilder.java	28 Jul 2003 15:57:15 -0000	1.3
  @@ -64,7 +64,6 @@
   
           buildValidationRules(datatypeElement, type, datatypeManager);
           buildConvertor(datatypeElement, type);
  -        buildSelectionList(datatypeElement, type);
   
           return type;
       }
  
  
  
  1.3       +0 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/StringTypeBuilder.java
  
  Index: StringTypeBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/datatype/typeimpl/StringTypeBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StringTypeBuilder.java	15 Jul 2003 14:09:25 -0000	1.2
  +++ StringTypeBuilder.java	28 Jul 2003 15:57:15 -0000	1.3
  @@ -67,7 +67,6 @@
   
           buildValidationRules(datatypeElement, type, datatypeManager);
           buildConvertor(datatypeElement, type);
  -        buildSelectionList(datatypeElement, type);
   
           return type;
       }
  
  
  
  1.8       +17 -2     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Field.java
  
  Index: Field.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Field.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Field.java	15 Jul 2003 14:11:48 -0000	1.7
  +++ Field.java	28 Jul 2003 15:57:15 -0000	1.8
  @@ -53,6 +53,8 @@
   import org.apache.cocoon.woody.Constants;
   import org.apache.cocoon.woody.FormContext;
   import org.apache.cocoon.woody.datatype.ValidationError;
  +import org.apache.cocoon.woody.datatype.SelectionList;
  +import org.apache.cocoon.woody.datatype.Datatype;
   import org.apache.cocoon.xml.AttributesImpl;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  @@ -74,6 +76,7 @@
       private Object value;
       private boolean conversionFailed;
       private ValidationError validationError;
  +    private SelectionList selectionList;
   
       public Field(FieldDefinition fieldDefinition) {
           this.definition = fieldDefinition;
  @@ -181,8 +184,10 @@
           contentHandler.endElement(Constants.WI_NS, LABEL_EL, Constants.WI_PREFIX_COLON
+ LABEL_EL);
   
           // the selection list, if any
  -        if (definition.getDatatype().getSelectionList() != null) {
  -            definition.getDatatype().getSelectionList().generateSaxFragment(contentHandler,
locale);
  +        if (selectionList != null) {
  +            selectionList.generateSaxFragment(contentHandler, locale);
  +        } else if (definition.getSelectionList() != null) {
  +            definition.getSelectionList().generateSaxFragment(contentHandler, locale);
           }
   
           contentHandler.endElement(Constants.WI_NS, FIELD_EL, Constants.WI_PREFIX_COLON
+ FIELD_EL);
  @@ -190,5 +195,15 @@
   
       public void generateLabel(ContentHandler contentHandler) throws SAXException {
           definition.generateLabel(contentHandler);
  +    }
  +
  +    public void setSelectionList(SelectionList selectionList) {
  +        if (selectionList != null && selectionList.getDatatype() != definition.getDatatype())
  +            throw new RuntimeException("Tried to assign a SelectionList that is not associated
with this widget's datatype.");
  +        this.selectionList = selectionList;
  +    }
  +
  +    public Datatype getDatatype() {
  +        return definition.getDatatype();
       }
   }
  
  
  
  1.2       +1 -12     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/FieldDefinition.java
  
  Index: FieldDefinition.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/FieldDefinition.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FieldDefinition.java	22 Apr 2003 12:04:19 -0000	1.1
  +++ FieldDefinition.java	28 Jul 2003 15:57:15 -0000	1.2
  @@ -50,26 +50,15 @@
   */
   package org.apache.cocoon.woody.formmodel;
   
  -import org.apache.cocoon.woody.datatype.Datatype;
  -
   /**
    * The {@link WidgetDefinition} part of a Field widget, see {@link Field} for more information.
    */
  -public class FieldDefinition extends AbstractWidgetDefinition {
  -    private Datatype datatype;
  +public class FieldDefinition extends AbstractDatatypeWidgetDefinition {
       private boolean required;
   
       public Widget createInstance() {
           Field field = new Field(this);
           return field;
  -    }
  -
  -    public Datatype getDatatype() {
  -        return datatype;
  -    }
  -
  -    public void setDatatype(Datatype datatype) {
  -        this.datatype = datatype;
       }
   
       public boolean isRequired() {
  
  
  
  1.2       +3 -2      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/FieldDefinitionBuilder.java
  
  Index: FieldDefinitionBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/FieldDefinitionBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FieldDefinitionBuilder.java	22 Apr 2003 12:04:19 -0000	1.1
  +++ FieldDefinitionBuilder.java	28 Jul 2003 15:57:15 -0000	1.2
  @@ -58,7 +58,7 @@
   /**
    * Builds {FieldDefinition}s.
    */
  -public class FieldDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
  +public class FieldDefinitionBuilder extends AbstractDatatypeWidgetDefinitionBuilder {
   
       public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception
{
           FieldDefinition fieldDefinition = new FieldDefinition();
  @@ -71,6 +71,8 @@
           Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
           fieldDefinition.setDatatype(datatype);
   
  +        buildSelectionList(widgetElement, fieldDefinition);
  +
           setLabel(widgetElement, fieldDefinition);
   
           boolean required = DomHelper.getAttributeAsBoolean(widgetElement, "required", false);
  @@ -78,5 +80,4 @@
   
           return fieldDefinition;
       }
  -
   }
  
  
  
  1.5       +1 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/MultiValueField.java
  
  Index: MultiValueField.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/MultiValueField.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MultiValueField.java	15 Jul 2003 14:11:48 -0000	1.4
  +++ MultiValueField.java	28 Jul 2003 15:57:15 -0000	1.5
  @@ -163,7 +163,7 @@
           contentHandler.endElement(Constants.WI_NS, LABEL_EL, Constants.WI_PREFIX_COLON
+ LABEL_EL);
   
           // the selection list (a MultiValueField has per definition always a SelectionList)
  -        definition.getDatatype().getSelectionList().generateSaxFragment(contentHandler,
locale);
  +        definition.getSelectionList().generateSaxFragment(contentHandler, locale);
   
           // validation message element
           if (validationError != null) {
  
  
  
  1.2       +5 -3      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/MultiValueFieldDefinitionBuilder.java
  
  Index: MultiValueFieldDefinitionBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/MultiValueFieldDefinitionBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultiValueFieldDefinitionBuilder.java	22 Apr 2003 12:04:19 -0000	1.1
  +++ MultiValueFieldDefinitionBuilder.java	28 Jul 2003 15:57:15 -0000	1.2
  @@ -58,7 +58,7 @@
   /**
    * Builds {@link MultiValueFieldDefinition}s.
    */
  -public class MultiValueFieldDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
  +public class MultiValueFieldDefinitionBuilder extends AbstractDatatypeWidgetDefinitionBuilder
{
       public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception
{
           MultiValueFieldDefinition definition = new MultiValueFieldDefinition();
   
  @@ -70,9 +70,11 @@
               throw new Exception("A nested datatype element is required for the widget specified
at " + DomHelper.getLocation(widgetElement));
   
           Datatype datatype = datatypeManager.createDatatype(datatypeElement, true);
  -        if (datatype.getSelectionList() == null)
  -            throw new Exception("Error: multivaluefields always require a selectionlist
at " + DomHelper.getLocation(datatypeElement));
           definition.setDatatype(datatype);
  +
  +        boolean hasSelectionList = buildSelectionList(widgetElement, definition);
  +        if (!hasSelectionList)
  +            throw new Exception("Error: multivaluefields always require a selectionlist
at " + DomHelper.getLocation(widgetElement));
   
           boolean required = DomHelper.getAttributeAsBoolean(widgetElement, "required", false);
           definition.setRequired(required);
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/AbstractDatatypeWidgetDefinition.java
  
  Index: AbstractDatatypeWidgetDefinition.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.woody.formmodel;
  
  import org.apache.cocoon.woody.datatype.Datatype;
  import org.apache.cocoon.woody.datatype.SelectionList;
  
  /**
   * Base class for WidgetDefinitions that use a Datatype and SelectionList.
   */
  public abstract class AbstractDatatypeWidgetDefinition extends AbstractWidgetDefinition
{
      private Datatype datatype;
      private SelectionList selectionList;
  
      public Datatype getDatatype() {
          return datatype;
      }
  
      public void setDatatype(Datatype datatype) {
          this.datatype = datatype;
      }
  
      public void setSelectionList(SelectionList selectionList) {
          if (selectionList.getDatatype() != getDatatype())
              throw new RuntimeException("Tried to assign a SelectionList that is not associated
with this widget's datatype.");
          this.selectionList = selectionList;
      }
  
      public SelectionList getSelectionList() {
          return selectionList;
      }
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java
  
  Index: AbstractDatatypeWidgetDefinitionBuilder.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.woody.formmodel;
  
  import org.w3c.dom.Element;
  import org.w3c.dom.Document;
  import org.apache.cocoon.woody.datatype.SelectionList;
  import org.apache.cocoon.woody.datatype.SelectionListBuilder;
  import org.apache.cocoon.woody.datatype.DynamicSelectionList;
  import org.apache.cocoon.woody.util.DomHelper;
  import org.apache.cocoon.woody.Constants;
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceResolver;
  import org.xml.sax.InputSource;
  
  /**
   * Abstract base class for WidgetDefinitionBuilders that build widgets that have datatypes/selection
lists.
   */
  public abstract class AbstractDatatypeWidgetDefinitionBuilder extends AbstractWidgetDefinitionBuilder
{
      /**
       * @return true if a selectionlist has actually been build.
       */
      protected boolean buildSelectionList(Element widgetElement, AbstractDatatypeWidgetDefinition
widget) throws Exception {
          Element selectionListElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS,
"selection-list");
          if (selectionListElement != null) {
              SelectionList selectionList;
              String src = selectionListElement.getAttribute("src");
              if (src.length() > 0) {
                  boolean dynamic = DomHelper.getAttributeAsBoolean(selectionListElement,
"dynamic", false);
                  if (!dynamic) {
                      selectionListElement = readSelectionList(src);
                      selectionList = SelectionListBuilder.build(selectionListElement, widget.getDatatype());
                  } else {
                      selectionList = new DynamicSelectionList(widget.getDatatype(), src,
serviceManager);
                  }
              } else {
                  // selection list is defined inline
                  selectionList = SelectionListBuilder.build(selectionListElement, widget.getDatatype());
              }
              widget.setSelectionList(selectionList);
              return true;
          } else
              return false;
      }
  
      private Element readSelectionList(String src) throws Exception {
          SourceResolver resolver = null;
          Source source = null;
          try {
              resolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
              source = resolver.resolveURI(src);
              InputSource inputSource = new InputSource(source.getInputStream());
              inputSource.setSystemId(source.getURI());
              Document document = DomHelper.parse(inputSource);
              Element selectionListElement = document.getDocumentElement();
              if (!Constants.WD_NS.equals(selectionListElement.getNamespaceURI()) || !"selection-list".equals(selectionListElement.getLocalName()))
                  throw new Exception("Excepted a wd:selection-list element at " + DomHelper.getLocation(selectionListElement));
              return selectionListElement;
          } finally {
              if (source != null)
                  resolver.release(source);
              if (resolver != null)
                  serviceManager.release(resolver);
          }
      }
  }
  
  
  
  1.7       +1 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/WidgetReplacingPipe.java
  
  Index: WidgetReplacingPipe.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/transformation/WidgetReplacingPipe.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WidgetReplacingPipe.java	26 Jul 2003 14:05:05 -0000	1.6
  +++ WidgetReplacingPipe.java	28 Jul 2003 15:57:16 -0000	1.7
  @@ -179,7 +179,7 @@
                   } else if (pipeContext.getAttributeName() != null) { // then see if an
attribute-name was specified
                       contextWidget = (Form)pipeContext.getRequest().getAttribute(pipeContext.getAttributeName());
                       if (contextWidget == null)
  -                        throw new SAXException("No form found in request attribute with
name \"" + pipeContext.getAttributeName());
  +                        throw new SAXException("No form found in request attribute with
name \"" + pipeContext.getAttributeName() + "\"");
                   } else { // and then see if we got a form from the flow
                       formJXPath = "/" + WoodyTemplateTransformer.WOODY_FORM;
                       Object form = null;
  
  
  

Mime
View raw message