cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/woody/samples/xsl/html woody-default.xsl
Date Thu, 13 Nov 2003 14:57:06 GMT
sylvain     2003/11/13 06:57:06

  Modified:    src/blocks/woody/conf woody-form.xconf
               src/blocks/woody/samples sitemap.xmap welcome.xml
               src/blocks/woody/samples/messages WoodyMessages.xml
                        WoodyMessages_it_IT.xml
               src/blocks/woody/samples/resources woody-field-styling.xsl
               src/blocks/woody/samples/xsl/html woody-default.xsl
  Added:       src/blocks/woody/java/org/apache/cocoon/woody/formmodel
                        Upload.java UploadDefinition.java
                        UploadDefinitionBuilder.java
               src/blocks/woody/samples/flow upload_example.js
               src/blocks/woody/samples/forms upload_model.xml
                        upload_success_jx.xml upload_template.xml
  Log:
  New upload widget!
  
  Revision  Changes    Path
  1.6       +1 -0      cocoon-2.1/src/blocks/woody/conf/woody-form.xconf
  
  Index: woody-form.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/conf/woody-form.xconf,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- woody-form.xconf	3 Nov 2003 17:05:32 -0000	1.5
  +++ woody-form.xconf	13 Nov 2003 14:57:05 -0000	1.6
  @@ -18,6 +18,7 @@
         <widget name="button" src="org.apache.cocoon.woody.formmodel.ButtonDefinitionBuilder"/>
         <widget name="aggregatefield" src="org.apache.cocoon.woody.formmodel.AggregateFieldDefinitionBuilder"/>
         <widget name="output" src="org.apache.cocoon.woody.formmodel.OutputDefinitionBuilder"/>
  +      <widget name="upload" src="org.apache.cocoon.woody.formmodel.UploadDefinitionBuilder"/>
       </widgets>
     </woody-formmanager>
   </xconf>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/Upload.java
  
  Index: Upload.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 java.util.Locale;
  import java.util.StringTokenizer;
  
  import org.apache.cocoon.servlet.multipart.Part;
  import org.apache.cocoon.woody.Constants;
  import org.apache.cocoon.woody.FormContext;
  import org.apache.cocoon.woody.datatype.ValidationError;
  import org.apache.cocoon.woody.util.I18nMessage;
  import org.apache.cocoon.xml.AttributesImpl;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  /**
   * A file-uploading Widget. This widget gives access via Woody, to Cocoon's 
   * file upload functionality.
   * 
   * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
   * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
   * @version CVS $Id: Upload.java,v 1.1 2003/11/13 14:57:05 sylvain Exp $
   */
  public class Upload extends AbstractWidget {
      private UploadDefinition definition;
      private Part part;
      private ValidationError validationError;
  
      public Upload(UploadDefinition uploadDefinition) {
          this.definition = uploadDefinition;
      }
  
      public UploadDefinition getUploadDefinition() {
          return this.definition;
      }
  
      public String getId() {
          return definition.getId();
      }
  
      public Object getValue() {
          return this.part;
      }
  
      public void setValue(Object object) {
          throw new RuntimeException("Cannot manually set the value of an upload widget for
field \"" + getFullyQualifiedId() + "\"");
      }
  
      public void readFromRequest(FormContext formContext) {
          Object obj = formContext.getRequest().get(getFullyQualifiedId());
          
          // If the request object is a Part, keep it
          if (obj instanceof Part) {
              Part requestPart = (Part)obj;
              if (this.part != null) {
                  // Replace the current part
                  this.part.dispose();
              }
          
              // Keep the request part
              requestPart.setDisposeWithRequest(false);
              this.part = requestPart;
              this.validationError = null;
              
          // If it's not a part and not null, clear any existing value
          // We also check if we're the submit widget, as a result of clicking the "..." button
          } else if (obj != null || getForm().getSubmitWidget() == this){
              // Clear the part, if any
              if (this.part != null) {
                  this.part.dispose();
                  this.part = null;
              }
              this.validationError = null;
          }
          
          // And keep the current state if the parameter doesn't exist or is null
      }
  
      public boolean validate(FormContext formContext) {
          if (this.part == null) {
              if (this.definition.isRequired()) {
                  this.validationError = new ValidationError(new I18nMessage("general.field-required",
Constants.I18N_CATALOGUE));
              }
          } else {
              String mimeTypes = this.definition.getMimeTypes();
              if (mimeTypes != null) {
                  StringTokenizer tok = new StringTokenizer(this.definition.getMimeTypes(),
", ");
                  this.validationError = new ValidationError(new I18nMessage("upload.invalid-type",
Constants.I18N_CATALOGUE));
                  String contentType = this.part.getMimeType();
                  while (tok.hasMoreTokens()) {
                      if (tok.nextToken().equals(contentType)) {
                          this.validationError = null;
                      }
                  }
              } else {
                  this.validationError = null;
              }
          }
          
          return validationError == null;
      }
  
      /**
       * Returns the validation error, if any. There will always be a validation error in
case the
       * {@link #validate} method returned false.
       */
      public ValidationError getValidationError() {
          return validationError;
      }
      
      /**
       * Set a validation error on this field. This allows fields to be externally marked
as invalid by
       * application logic.
       * 
       * @param error the validation error
       */
      public void setValidationError(ValidationError error) {
          this.validationError = error;
      }
  
      private static final String FIELD_EL = "upload";
      private static final String VALUE_EL = "value";
      private static final String VALIDATION_MSG_EL = "validation-message";
  
      public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws
SAXException {
          AttributesImpl fieldAttrs = new AttributesImpl();
          fieldAttrs.addCDATAAttribute("id", getFullyQualifiedId());
          fieldAttrs.addCDATAAttribute("required", String.valueOf(definition.isRequired()));
          if (definition.getMimeTypes() != null) {
              fieldAttrs.addCDATAAttribute("mime-types", definition.getMimeTypes());
          }
          contentHandler.startElement(Constants.WI_NS, FIELD_EL, Constants.WI_PREFIX_COLON
+ FIELD_EL, fieldAttrs);
  
          if (this.part != null) {
              String name = (String)this.part.getHeaders().get("filename");
              contentHandler.startElement(Constants.WI_NS, VALUE_EL, Constants.WI_PREFIX_COLON
+ VALUE_EL, Constants.EMPTY_ATTRS);
              contentHandler.characters(name.toCharArray(), 0, name.length());
              contentHandler.endElement(Constants.WI_NS, VALUE_EL, Constants.WI_PREFIX_COLON
+ VALUE_EL);
          }
  
          // validation message element: only present if the value is not valid
          if (validationError != null) {
              contentHandler.startElement(Constants.WI_NS, VALIDATION_MSG_EL, Constants.WI_PREFIX_COLON
+ VALIDATION_MSG_EL, Constants.EMPTY_ATTRS);
              validationError.generateSaxFragment(contentHandler);
              contentHandler.endElement(Constants.WI_NS, VALIDATION_MSG_EL, Constants.WI_PREFIX_COLON
+ VALIDATION_MSG_EL);
          }
  
          // the display data
          this.definition.generateDisplayData(contentHandler);
  
          contentHandler.endElement(Constants.WI_NS, FIELD_EL, Constants.WI_PREFIX_COLON +
FIELD_EL);
      }
  
      public void generateLabel(ContentHandler contentHandler) throws SAXException {
          definition.generateLabel(contentHandler);
      }
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/UploadDefinition.java
  
  Index: UploadDefinition.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;
  
  /**
   * The definition of an upload widget.
   * 
   * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
   * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
   * @version CVS $Id: UploadDefinition.java,v 1.1 2003/11/13 14:57:05 sylvain Exp $
   */
  public class UploadDefinition extends AbstractWidgetDefinition {
      private boolean required;
      private String mimeTypes;
      
      public UploadDefinition(boolean required, String mimeTypes) {
          this.required = required;
          this.mimeTypes = mimeTypes;
      }
  
      public Widget createInstance() {
          Upload upload = new Upload(this);
          return upload;
      }
  
      public boolean isRequired() {
          return required;
      }
      
      public String getMimeTypes() {
          return this.mimeTypes;
      }
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/UploadDefinitionBuilder.java
  
  Index: UploadDefinitionBuilder.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.util.DomHelper;
  import org.w3c.dom.Element;
  
  /**
   * Builds {@link org.apache.cocoon.woody.formmodel.UploadDefinition}s.
   * 
   * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
   * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
   * @version CVS $Id: UploadDefinitionBuilder.java,v 1.1 2003/11/13 14:57:05 sylvain Exp
$
   */
  public class UploadDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
  
      public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception
{
          String mimeTypes = DomHelper.getAttribute(widgetElement, "mime-types", null);
          boolean required = DomHelper.getAttributeAsBoolean(widgetElement, "required", false);
          
          UploadDefinition uploadDefinition = new UploadDefinition(required, mimeTypes);
          setId(widgetElement, uploadDefinition);
  
          setDisplayData(widgetElement, uploadDefinition);
  
          return uploadDefinition;
      }
  }
  
  
  
  1.27      +43 -0     cocoon-2.1/src/blocks/woody/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/sitemap.xmap,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- sitemap.xmap	9 Nov 2003 18:55:03 -0000	1.26
  +++ sitemap.xmap	13 Nov 2003 14:57:05 -0000	1.27
  @@ -54,6 +54,7 @@
     <map:flow language="javascript">
       <map:script src="flow/woody_flow_example.js"/>
       <map:script src="flow/binding_example.js"/>
  +    <map:script src="flow/upload_example.js"/>
       <map:script src="flow/registration.js"/>
     </map:flow>
   
  @@ -173,6 +174,48 @@
          <map:serialize/>
        </map:match>
   
  +
  +    <!-- Upload Widget Sample -->
  +
  +     <map:match pattern="upload">
  +       <map:call function="upload"/>
  +     </map:match>
  +
  +     <map:match pattern="*.continue">
  +       <map:call continuation="{1}"/>
  +     </map:match>
  +
  +     <map:match pattern="upload-display-pipeline">
  +       <!-- pipeline to show the form -->
  +       <map:generate src="forms/upload_template.xml"/>
  +       <map:transform type="woody"/>
  +       <map:transform type="i18n">
  +         <map:parameter name="locale" value="en-US"/>
  +       </map:transform>
  +       <map:transform type="i18n">
  +         <map:parameter name="locale" value="en-US"/>
  +       </map:transform>
  +       <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
  +         <map:parameter name="contextPath" value="{request:contextPath}"/>
  +         <map:parameter name="servletPath" value="{request:servletPath}"/>
  +         <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
  +         <map:parameter name="file" value="forms/form1_template_flow.xml"/>
  +         <map:parameter name="remove" value="{0}"/>
  +       </map:transform> 
  +       <map:transform src="resources/woody-samples-styling.xsl"/>
  +       <map:serialize/>
  +     </map:match>
  +
  +     <map:match pattern="upload-success-pipeline">
  +       <map:generate type="jx" src="forms/upload_success_jx.xml"/>
  +       <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
  +         <map:parameter name="contextPath" value="{request:contextPath}"/>
  +         <map:parameter name="servletPath" value="{request:servletPath}"/>
  +         <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
  +         <map:parameter name="file" value="forms/form1_success.xsp"/>
  +       </map:transform>
  +       <map:serialize/>
  +     </map:match>
   
        <!--
           | Binding form sample, using flowscript
  
  
  
  1.8       +1 -0      cocoon-2.1/src/blocks/woody/samples/welcome.xml
  
  Index: welcome.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/welcome.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- welcome.xml	8 Nov 2003 16:37:51 -0000	1.7
  +++ welcome.xml	13 Nov 2003 14:57:05 -0000	1.8
  @@ -18,6 +18,7 @@
     <sample name="Flowscript" href="form1.flow">The same sample as above using Flowscript.</sample>
     <sample name="Registration" href="registration">A simple registration form.</sample>
     <sample name="Car selector" href="carselector">Illustrates programmatically changing
selectionlists.</sample>
  +  <sample name="Upload" href="upload">Shows an upload widget used with Flowscript</sample>
    </group>
   
    <group name="Binding Samples">
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/flow/upload_example.js
  
  Index: upload_example.js
  ===================================================================
  cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody2.js");
  
  function upload() {
      
      var form = new Form("forms/upload_model.xml");
      var k = form.showForm("upload-display-pipeline");
  
      k.invalidate();
  
      cocoon.sendPage("upload-success-pipeline",
          {
              uploadContent: handleUpload(form), 
              username: form.getWidget("user").getValue(),
              filename: form.getWidget("upload").getValue().getHeaders().get("filename")
          }
      );
  }
  
  function handleUpload(form) {
  
    var buf = new java.lang.StringBuffer();
    
    var uploadWidget = form.getWidget("upload");
    if (uploadWidget.getValue() != null) {
      var stream = uploadWidget.getValue().getInputStream();
      var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
  
      var line;
      while ((line=reader.readLine())!=null)
        buf.append(line).append("\n");
  
      reader.close();
    }
    
    return buf.toString();
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/forms/upload_model.xml
  
  Index: upload_model.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <wd:form xmlns:wd="http://apache.org/cocoon/woody/definition/1.0" xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
    <wd:widgets>
    
      <wd:field id="user" required="true">
        <wd:datatype base="string"/>
        <wd:label>User name</wd:label>
      </wd:field>
      
      <wd:upload id="upload" mime-types="text/plain" required="true">
        <wd:label>Upload a text file</wd:label>
        <wd:hint>You must choose a text file</wd:hint>
      </wd:upload>
      
    </wd:widgets>
  </wd:form>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/forms/upload_success_jx.xml
  
  Index: upload_success_jx.xml
  ===================================================================
  <?xml version="1.0"?>
  <page>
    <title>Sample form result</title>
    <content>
      User '${username}' uploaded file '${filename}' whose content is :
      <br/>
      <pre>
  ${uploadContent}
      </pre>
    </content>
  </page>
  
  
  
  1.1                  cocoon-2.1/src/blocks/woody/samples/forms/upload_template.xml
  
  Index: upload_template.xml
  ===================================================================
  <?xml version="1.0"?>
  <page xmlns:wt="http://apache.org/cocoon/woody/template/1.0">
    <title>Upload Sample</title>
    <content>
      <para>
      For this example to work, you must enable uploads in your web.xml file.
      </para>
      <wt:form-template action="#{$continuation/id}.continue" method="POST" enctype="multipart/form-data">
        <table>
          <tr>
            <td valign="top"><wt:widget-label id="user"/></td>
            <td valign="top"><wt:widget id="user"/></td>
          </tr>
          <tr>
            <td valign="top"><wt:widget-label id="upload"/></td>
            <td valign="top"><wt:widget id="upload"/></td>
          </tr>
        </table>
        <input type="submit"/>
      </wt:form-template>
    </content>
  </page>
  
  
  
  1.6       +1 -1      cocoon-2.1/src/blocks/woody/samples/messages/WoodyMessages.xml
  
  Index: WoodyMessages.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/messages/WoodyMessages.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WoodyMessages.xml	15 Jul 2003 14:14:38 -0000	1.5
  +++ WoodyMessages.xml	13 Nov 2003 14:57:06 -0000	1.6
  @@ -30,5 +30,5 @@
   
   
     <message key="aggregatedfield.split-failed">Content of this field does not match
the following regular expression: {0}</message>
  -
  +  <message key="upload.invalid-type">Invalid content type.</message>
   </catalogue>
  
  
  
  1.2       +1 -1      cocoon-2.1/src/blocks/woody/samples/messages/WoodyMessages_it_IT.xml
  
  Index: WoodyMessages_it_IT.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/messages/WoodyMessages_it_IT.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WoodyMessages_it_IT.xml	23 Oct 2003 07:41:53 -0000	1.1
  +++ WoodyMessages_it_IT.xml	13 Nov 2003 14:57:06 -0000	1.2
  @@ -30,5 +30,5 @@
   
   
     <message key="aggregatedfield.split-failed">Il valore non corrisponde alla seguente
espressione regolare: {0}</message>
  -
  +  <message key="upload.invalid-type">(TODO)Invalid content type.</message>
   </catalogue>
  
  
  
  1.9       +18 -0     cocoon-2.1/src/blocks/woody/samples/resources/woody-field-styling.xsl
  
  Index: woody-field-styling.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/resources/woody-field-styling.xsl,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- woody-field-styling.xsl	7 Nov 2003 16:38:02 -0000	1.8
  +++ woody-field-styling.xsl	13 Nov 2003 14:57:06 -0000	1.9
  @@ -297,6 +297,24 @@
       </span>
       <xsl:call-template name="woody-field-common"/>
     </xsl:template>
  +  
  +  <!--
  +    wi:upload
  +  -->
  +  <xsl:template match="wi:upload">
  +    <xsl:choose>
  +      <xsl:when test="wi:value">
  +        <!-- Has a value (filename): display it with a change button -->
  +        <span title="{wi:hint}">
  +          [<xsl:value-of select="wi:value"/>] <input type="submit" id="{@id}"
name="{@id}" value="..."/>
  +        </span>
  +      </xsl:when>
  +      <xsl:otherwise>
  +        <input type="file" id="{@id}" name="{@id}" title="{wi:hint}" accept="{@mime-types}"/>
  +      </xsl:otherwise>
  +    </xsl:choose>
  +    <xsl:call-template name="woody-field-common"/>
  +  </xsl:template>
   
     <!--
       wi:repeater
  
  
  
  1.13      +39 -1     cocoon-2.1/src/blocks/woody/samples/xsl/html/woody-default.xsl
  
  Index: woody-default.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/xsl/html/woody-default.xsl,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- woody-default.xsl	1 Nov 2003 11:25:54 -0000	1.12
  +++ woody-default.xsl	13 Nov 2003 14:57:06 -0000	1.13
  @@ -9,8 +9,24 @@
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:wi="http://apache.org/cocoon/woody/instance/1.0">
   
  -  <xsl:template match="wi:field">
  +  <xsl:template match="wi:upload">
  +    <input name="{@id}" value="{wi:value}" type="file">
  +      <xsl:if test="wi:styling">
  +        <xsl:copy-of select="wi:styling/@*"/>
  +      </xsl:if>
  +    </input>
  +
  +    <xsl:if test="wi:validation-message">
  +      <xsl:call-template name="validation-message">
  +        <xsl:with-param name="message" select="wi:validation-message"/>
  +      </xsl:call-template>
  +    </xsl:if>
  +    <xsl:if test="@required='true'">
  +      <b>*</b>
  +    </xsl:if>
  +  </xsl:template>
   
  +  <xsl:template match="wi:field">
       <xsl:choose>
         <xsl:when test="wi:selection-list">
           <xsl:call-template name="field-with-selection-list">
  @@ -142,6 +158,27 @@
       </xsl:for-each>
     </xsl:template>
   
  +  <xsl:template match="wi:upload">
  +    <input name="{@id}" type="file">
  +      <xsl:if test="wi:styling">
  +        <xsl:copy-of select="wi:styling/@*"/>
  +      </xsl:if>
  +    </input>
  +    
  +    <xsl:if test="string-length(wi:value)&gt;0">
  +      [<xsl:value-of select="wi:value"/>]
  +    </xsl:if>
  +    
  +    <xsl:if test="wi:validation-message">
  +      <xsl:call-template name="validation-message">
  +        <xsl:with-param name="message" select="wi:validation-message"/>
  +      </xsl:call-template>
  +    </xsl:if>
  +    <xsl:if test="@required='true'">
  +      <b>*</b>
  +    </xsl:if>
  +  </xsl:template>
  +
     <xsl:template match="wi:repeater">
       <input type="hidden" name="{@id}.size" value="{@size}"/>
       <table border="1">
  @@ -175,6 +212,7 @@
     </xsl:template>
     
     <xsl:template match="wi:form">
  +  FORM
       <table border="1">
         <xsl:for-each select="wi:children/*">
           <tr>
  
  
  

Mime
View raw message