cancel
Showing results for 
Search instead for 
Did you mean: 

quick upload

sjeek
Champ in-the-making
Champ in-the-making
Hi,

When you want to upload a file, you always get to follow certain steps.
Now, I placed a new link (at the left of the 'add content' link) for a quick upload.
that means:
If i click on the link, there must be a new windows (for choosing the files) and if i select the file, the file must be automatically join the content in the space.

Could it be possible?

When i click on the link, I would open a "browse window"
How can i do this with a link?

(or does anyone have a better idea but with a button? )

The priority is to add a content with 1 or 2 clicks (maby 3?)

grtz
4 REPLIES 4

gavinc
Champ in-the-making
Champ in-the-making
To open a link in a new window you use the target="new" attribute.

sjeek
Champ in-the-making
Champ in-the-making
yes, I now that  Smiley Happy

But, the goal here is, to upload a content, with 1 or 2 clicks
so, when I click on a link (it must be the same action, then, when you click on 'browse' to upload a file), you can choose a file en it would be saved directlly in to the repository. (if that is possible)

sjeek
Champ in-the-making
Champ in-the-making
allright

Now, I added a new "browse" content just at the right of the "add content" link.


<r:uploadForm>
                                <td style="padding-left:4px" align=right>
                                       <input type="file" name="alfFileInput"/>
                         </td>
                         <td style="padding-left:4px" align=left>
                                        <input style="margin-left:12px;" type="submit" value="<%=Application.getMessage(FacesContext.getCurrentInstance(), "upload")%>" />
                         </td>
                       <%
                                 QuickUpload bean = (QuickUpload)session.getAttribute(AlfrescoFacesPortlet.MANAGED_BEAN_PREFIX + "QuickUpload");
                                 if (bean == null)
                                 {
                                    bean = (QuickUpload)session.getAttribute("QuickUpload");
                                 }
                                 if (bean != null && bean.getFileName() != null) {
                                 %>
                                 <td>
                                 <%=bean.getFileUploadSuccessMsg()%>
                                 </td>
                                <% } %>
                      </r:uploadForm>

In QuickUpload, I have this (for the moment because I don't know witch other methods i just have to use)


/*
* Copyright (C) 2005 Alfresco, Inc.
*/
package jnj.alfresco.web.bean;

imports


public class QuickUpload {

   /**
    * @return Returns the message to display when a file has been uploaded
    */
   public String getFileUploadSuccessMsg() {
      String msg = Application.getMessage(FacesContext.getCurrentInstance(),
            "file_upload_success");
      return MessageFormat.format(msg, new Object[] { getFileName() });
   }
   
   /**
    * @return Returns the name of the file
    */
   public String getFileName() {
      // try and retrieve the file and filename from the file upload bean
      // representing the file we previously uploaded.
      FacesContext ctx = FacesContext.getCurrentInstance();
      FileUploadBean fileBean = (FileUploadBean) ctx.getExternalContext()
            .getSessionMap().get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
      if (fileBean != null) {
         this.file = fileBean.getFile();
         this.fileName = fileBean.getFileName();
      }

      return this.fileName;
   }
   
      /**
       * @param fileName The name of the file
       */
      public void setFileName(String fileName)
      {
         this.fileName = fileName;
        
         // we also need to keep the file upload bean in sync
         FacesContext ctx = FacesContext.getCurrentInstance();
         FileUploadBean fileBean = (FileUploadBean)ctx.getExternalContext().getSessionMap().
            get(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
         if (fileBean != null)
         {
            fileBean.setFileName(this.fileName);
         }
      }
     
      /**
       * Deletes the uploaded file and removes the FileUploadBean from the session
       */
      private void clearUpload()
      {
         // delete the temporary file we uploaded earlier
         if (this.file != null)
         {
            this.file.delete();
         }
        
         // remove the file upload bean from the session
         FacesContext ctx = FacesContext.getCurrentInstance();
         ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
      }


   
   /** transient form and upload properties */
   private File file;
   
   private String fileName;


}


<managed-bean>  
         <description>A bean that handles the quick uploads
         </description>
         <managed-bean-name>QuickUpload</managed-bean-name>   
         <managed-bean-class>jnj.alfresco.web.bean.QuickUpload</managed-bean-class>   
         <managed-bean-scope>session</managed-bean-scope> 
   </managed-bean>

Now, I just want to test, if the file definitly is beining uploaden by showing the getFileUploadSuccessMsg
But I don't get that message

What would be wrong here?

lmoulin
Champ in-the-making
Champ in-the-making
try the following code:
<%=bean.fileUploadSuccessMsg()%>

instead of

<%=bean.getFileUploadSuccessMsg()%>