You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2002/09/17 17:54:05 UTC

cvs commit: xml-cocoon2/src/webapp/docs/samples/xsp upload.xsp

vgritsenko    2002/09/17 08:54:04

  Modified:    .        Tag: cocoon_2_0_3_branch changes.xml
               src/java/org/apache/cocoon/components/request/multipart Tag:
                        cocoon_2_0_3_branch FilePartArray.java
                        FilePartFile.java
               src/webapp/docs/samples/xsp Tag: cocoon_2_0_3_branch
                        upload.xsp
  Log:
  improve file uploading backward compatibility
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.138.2.49 +5 -1      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.138.2.48
  retrieving revision 1.138.2.49
  diff -u -r1.138.2.48 -r1.138.2.49
  --- changes.xml	11 Sep 2002 12:43:57 -0000	1.138.2.48
  +++ changes.xml	17 Sep 2002 15:54:04 -0000	1.138.2.49
  @@ -39,6 +39,10 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="VG" type="update">
  +    Improve backward compatibility: FilePartFile needs toString() method to
  +    work with code written for Cocoon 2.0.
  +  </action>
     <action dev="SW" type="fix">
       AbstractServerPages used static fields for dependency tracking, which caused
       either non-modified XSPs to be recompiled, or modified XSPs not to be recompiled.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +1 -4      xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java
  
  Index: FilePartArray.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- FilePartArray.java	15 Jul 2002 14:10:35 -0000	1.1.2.2
  +++ FilePartArray.java	17 Sep 2002 15:54:04 -0000	1.1.2.3
  @@ -81,15 +81,12 @@
        *
        */
       public String getFileName() {
  -
           File f = new File((String) headers.get("filename"));
  -
           return f.getName();
       }
   
       /**
        * Returns a (ByteArray)InputStream containing the file data
  -     *
        *
        * @throws Exception
        */
  
  
  
  1.1.2.3   +9 -5      xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java
  
  Index: FilePartFile.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- FilePartFile.java	15 Jul 2002 14:10:35 -0000	1.1.2.2
  +++ FilePartFile.java	17 Sep 2002 15:54:04 -0000	1.1.2.3
  @@ -73,13 +73,12 @@
        * @param file
        */
       protected FilePartFile(Map headers, File file) {
  -	super(headers);
  +        super(headers);
           this.file = file;
       }
   
       /**
        * Returns the filename
  -     *
        */
       public String getFileName() {
           return file.getName();
  @@ -87,7 +86,6 @@
   
       /**
        * Returns the file
  -     *
        */
       public File getFile() {
           return file;
  @@ -96,10 +94,16 @@
       /**
        * Returns a (ByteArray)InputStream containing the file data
        *
  -     *
        * @throws Exception
        */
       public InputStream getInputStream() throws Exception {
           return new FileInputStream(file);
  +    }
  +
  +    /**
  +     * Returns the filename
  +     */
  +    public String toString() {
  +        return getFileName();
       }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +40 -18    xml-cocoon2/src/webapp/docs/samples/xsp/Attic/upload.xsp
  
  Index: upload.xsp
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/docs/samples/xsp/Attic/upload.xsp,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- upload.xsp	9 Feb 2002 06:21:57 -0000	1.3
  +++ upload.xsp	17 Sep 2002 15:54:04 -0000	1.3.2.1
  @@ -27,31 +27,53 @@
        <para>
          <form method="post" enctype="multipart/form-data" action="upload">
            File:  <input type="file" name="uploaded_file" size="50" />
  -     <p><input type="submit" value="Upload File" /></p>
  +         <p>
  +           <input type="submit" value="Upload File" />
  +         </p>
          </form>
        </para>
        <para>
  -     <ul>
          <xsp:logic>
  -        getLogger().debug("Dir=" + uploadDir);
  -         String[] filelist = uploadDir.list();
  -         <![CDATA[
  -         getLogger().debug("List=" + filelist.length);
  -         for (int i = 0; i < filelist.length; i++) {
  -            getLogger().debug("File [" + i + "]=" + filelist[i]);
  -         ]]>
  -           <li>
  -             <xsp:expr>filelist[i]</xsp:expr>
  -           </li>
  -         <![CDATA[
  +         if (<xsp-request:get-parameter name="uploaded_file"/> != null) {
  +           <xsp:content>
  +             Parameter uploaded_file:
  +             <strong>
  +               <xsp-request:get-parameter name="uploaded_file"/>
  +             </strong>
  +             <br/>
  +
  +             Parameter uploaded_file is instance of:
  +             <!-- note usage of get() instead of getParameter() -->
  +             <strong>
  +               <xsp:expr>
  +                 request.get("uploaded_file").getClass()
  +               </xsp:expr>
  +             </strong>
  +             <br/>
  +           </xsp:content>
            }
  -         ]]>
          </xsp:logic>
  -     </ul>
  +
  +       Upload directory content:
  +       <ul>
  +         <xsp:logic>
  +          getLogger().debug("Dir=" + uploadDir);
  +           String[] filelist = uploadDir.list();
  +           <![CDATA[
  +           getLogger().debug("List=" + filelist.length);
  +           for (int i = 0; i < filelist.length; i++) {
  +              getLogger().debug("File [" + i + "]=" + filelist[i]);
  +           ]]>
  +             <li>
  +               <xsp:expr>filelist[i]</xsp:expr>
  +             </li>
  +           <![CDATA[
  +           }
  +           ]]>
  +         </xsp:logic>
  +       </ul>
        </para>
        <para>Brought to you by Cocoon at <xsp:expr>new Date()</xsp:expr>.</para>
  -
      </content>
     </page>
   </xsp:page>
  -
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org