04-05-2006 10:06 AM
04-05-2006 05:36 PM
04-06-2006 02:22 AM
04-06-2006 08:32 AM
<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>
/*
* 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>
02-06-2008 03:56 AM
<%=bean.fileUploadSuccessMsg()%><%=bean.getFileUploadSuccessMsg()%>
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.