adding support for wcm tinymce extensions to create html from web content wizard

- extracted file picker backing code into its own bean
- refactoring for to extract file picker bean
- refactoring to manage uploads from file picker outside of xforms context
- added some language utility methods to common.js
- refactored extension dialogs to deal with quirkyness of tinymce dialog codebase on IE - mostly works now and addressed bug WCM-471
- resourcifying a couple strings i missed in filepickerbean

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5675 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2007-05-14 22:03:10 +00:00
parent bd54cd2401
commit df32d0ddf1
18 changed files with 615 additions and 411 deletions

View File

@@ -98,7 +98,9 @@ public class AVMEditBean
/** The NodeService bean reference */
protected NodeService nodeService;
/** The FilePickerBean reference */
protected FilePickerBean filePickerBean;
// ------------------------------------------------------------------------------
// Bean property getters and setters
@@ -106,7 +108,7 @@ public class AVMEditBean
/**
* @param avmService The AVMService to set.
*/
public void setAvmService(AVMService avmService)
public void setAvmService(final AVMService avmService)
{
this.avmService = avmService;
}
@@ -114,7 +116,7 @@ public class AVMEditBean
/**
* @param avmSyncService The AVMSyncService to set.
*/
public void setAvmSyncService(AVMSyncService avmSyncService)
public void setAvmSyncService(final AVMSyncService avmSyncService)
{
this.avmSyncService = avmSyncService;
}
@@ -122,15 +124,23 @@ public class AVMEditBean
/**
* @param avmBrowseBean The AVMBrowseBean to set.
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
public void setAvmBrowseBean(final AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param filePickerBean The FilePickerBean to set.
*/
public void setFilePickerBean(final FilePickerBean filePickerBean)
{
this.filePickerBean = filePickerBean;
}
/**
* @param contentService The ContentService to set.
*/
public void setContentService(ContentService contentService)
public void setContentService(final ContentService contentService)
{
this.contentService = contentService;
}
@@ -138,7 +148,7 @@ public class AVMEditBean
/**
* @param nodeService The nodeService to set.
*/
public void setNodeService(NodeService nodeService)
public void setNodeService(final NodeService nodeService)
{
this.nodeService = nodeService;
}
@@ -364,6 +374,8 @@ public class AVMEditBean
this.avmSyncService.resetLayer(path);
}
this.filePickerBean.clearUploadedFiles();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Editing AVM node: " + avmPath);
@@ -453,26 +465,26 @@ public class AVMEditBean
if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
this.regenerateRenditions();
final NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles();
if (LOGGER.isDebugEnabled())
LOGGER.debug("updating " + uploadedFiles.length + " uploaded files");
final List<AVMDifference> diffList = new ArrayList<AVMDifference>(uploadedFiles.length);
for (NodeRef uploadedFile : uploadedFiles)
{
final String path = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond();
diffList.add(new AVMDifference(-1, path,
-1, AVMUtil.getCorrespondingPathInMainStore(path),
AVMDifference.NEWER));
}
this.avmSyncService.update(diffList, null, true, true, true, true, null, null);
}
final NodeRef[] uploadedFiles = this.filePickerBean.getUploadedFiles();
if (LOGGER.isDebugEnabled())
LOGGER.debug("updating " + uploadedFiles.length + " uploaded files");
final List<AVMDifference> diffList = new ArrayList<AVMDifference>(uploadedFiles.length);
for (NodeRef uploadedFile : uploadedFiles)
{
final String path = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond();
diffList.add(new AVMDifference(-1, path,
-1, AVMUtil.getCorrespondingPathInMainStore(path),
AVMDifference.NEWER));
}
this.avmSyncService.update(diffList, null, true, true, true, true, null, null);
// Possibly notify virt server
AVMUtil.updateVServerWebapp(avmNode.getPath(), false);
resetState();
this.resetState();
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
}
@@ -559,6 +571,7 @@ public class AVMEditBean
this.setFormProcessorSession(null);
this.instanceDataDocument = null;
this.form = null;
this.filePickerBean.clearUploadedFiles();
}
/**

View File

@@ -118,6 +118,9 @@ public class CreateWebContentWizard extends BaseContentWizard
/** Workflow service bean reference */
protected WorkflowService workflowService;
/** The FilePickerBean reference */
protected FilePickerBean filePickerBean;
/**
* @param avmService The AVMService to set.
@@ -159,6 +162,14 @@ public class CreateWebContentWizard extends BaseContentWizard
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param filePickerBean The FilePickerBean to set.
*/
public void setFilePickerBean(final FilePickerBean filePickerBean)
{
this.filePickerBean = filePickerBean;
}
// ------------------------------------------------------------------------------
@@ -185,7 +196,8 @@ public class CreateWebContentWizard extends BaseContentWizard
this.formSelectDisabled = false;
this.createMimeTypes = null;
this.formChoices = null;
this.filePickerBean.clearUploadedFiles();
// check for a form ID being passed in as a parameter
if (this.parameters.get(UIUserSandboxes.PARAM_FORM_NAME) != null)
{
@@ -279,9 +291,7 @@ public class CreateWebContentWizard extends BaseContentWizard
protected String finishImpl(final FacesContext context, final String outcome)
throws Exception
{
final NodeRef[] uploadedFiles = (this.formProcessorSession != null
? this.formProcessorSession.getUploadedFiles()
: new NodeRef[0]);
final NodeRef[] uploadedFiles = this.filePickerBean.getUploadedFiles();
final List<AVMDifference> diffList =
new ArrayList<AVMDifference>(1 + this.renditions.size() + uploadedFiles.length);
diffList.add(new AVMDifference(-1, this.createdPath,
@@ -415,6 +425,7 @@ public class CreateWebContentWizard extends BaseContentWizard
{
this.formProcessorSession.destroy();
}
this.filePickerBean.clearUploadedFiles();
// return the default outcome
return outcome;
@@ -741,7 +752,7 @@ public class CreateWebContentWizard extends BaseContentWizard
return Collections.EMPTY_LIST;
}
NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles();
final NodeRef[] uploadedFiles = this.filePickerBean.getUploadedFiles();
final List<UIListItem> result =
new ArrayList<UIListItem>(uploadedFiles.length);

View File

@@ -0,0 +1,289 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.web.bean.wcm;
import java.io.*;
import java.util.*;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.TempFileProvider;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.app.servlet.ajax.InvokeCommand;
import org.alfresco.web.bean.FileUploadBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.*;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.servlet.ServletRequestContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.FileCopyUtils;
import org.w3c.dom.*;
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.ls.*;
import org.xml.sax.SAXException;
/**
* Bean for interacting with the file picker widget using ajax requests.
*/
public class FilePickerBean
{
private static final Log LOGGER = LogFactory.getLog(FilePickerBean.class);
private final Set<NodeRef> uploads = new HashSet<NodeRef>();
private AVMBrowseBean avmBrowseBean;
private AVMService avmService;
public FilePickerBean()
{
}
public void clearUploadedFiles()
{
this.uploads.clear();
}
public NodeRef[] getUploadedFiles()
{
return (NodeRef[])this.uploads.toArray(new NodeRef[this.uploads.size()]);
}
/**
* @param avmBrowseBean the avmBrowseBean to set.
*/
public void setAvmBrowseBean(final AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param avmService the avmService to set.
*/
public void setAvmService(final AVMService avmService)
{
this.avmService = avmService;
}
/**
* Provides data for a file picker widget.
*/
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_XML)
public void getFilePickerData()
throws Exception
{
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ExternalContext externalContext = facesContext.getExternalContext();
final Map requestParameters = externalContext.getRequestParameterMap();
String currentPath = (String)requestParameters.get("currentPath");
if (currentPath == null)
{
currentPath = this.getCurrentAVMPath();
}
else
{
final String previewStorePath =
AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath());
currentPath = AVMUtil.buildPath(previewStorePath,
currentPath,
AVMUtil.PathRelation.WEBAPP_RELATIVE);
}
LOGGER.debug(this + ".getFilePickerData(" + currentPath + ")");
final Document result = XMLUtil.newDocument();
final Element filePickerDataElement = result.createElement("file-picker-data");
result.appendChild(filePickerDataElement);
final AVMNodeDescriptor currentNode = this.avmService.lookup(-1, currentPath);
if (currentNode == null)
{
final Element errorElement = result.createElement("error");
errorElement.appendChild(result.createTextNode("Path " + currentPath + " not found"));
filePickerDataElement.appendChild(errorElement);
currentPath = this.getCurrentAVMPath();
}
else if (! currentNode.isDirectory())
{
currentPath = AVMNodeConverter.SplitBase(currentPath)[0];
}
Element e = result.createElement("current-node");
e.setAttribute("avmPath", currentPath);
e.setAttribute("webappRelativePath",
AVMUtil.getWebappRelativePath(currentPath));
e.setAttribute("type", "directory");
e.setAttribute("image", "/images/icons/space_small.gif");
filePickerDataElement.appendChild(e);
for (Map.Entry<String, AVMNodeDescriptor> entry :
this.avmService.getDirectoryListing(-1, currentPath).entrySet())
{
e = result.createElement("child-node");
e.setAttribute("avmPath", entry.getValue().getPath());
e.setAttribute("webappRelativePath",
AVMUtil.getWebappRelativePath(entry.getValue().getPath()));
e.setAttribute("type", entry.getValue().isDirectory() ? "directory" : "file");
e.setAttribute("image", (entry.getValue().isDirectory()
? "/images/icons/space_small.gif"
: Utils.getFileTypeImage(facesContext,
entry.getValue().getName(),
true)));
filePickerDataElement.appendChild(e);
}
final ResponseWriter out = facesContext.getResponseWriter();
XMLUtil.print(result, out);
out.close();
}
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
public void uploadFile()
throws Exception
{
LOGGER.debug(this + ".uploadFile()");
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ExternalContext externalContext = facesContext.getExternalContext();
final HttpServletRequest request = (HttpServletRequest)
externalContext.getRequest();
final ServletFileUpload upload =
new ServletFileUpload(new DiskFileItemFactory());
upload.setHeaderEncoding("UTF-8");
final List<FileItem> fileItems = upload.parseRequest(request);
final FileUploadBean bean = new FileUploadBean();
String uploadId = null;
String currentPath = null;
String filename = null;
String returnPage = null;
InputStream fileInputStream = null;
for (FileItem item : fileItems)
{
LOGGER.debug("item = " + item);
if (item.isFormField() && item.getFieldName().equals("upload-id"))
{
uploadId = item.getString();
LOGGER.debug("uploadId is " + uploadId);
}
if (item.isFormField() && item.getFieldName().equals("return-page"))
{
returnPage = item.getString();
LOGGER.debug("returnPage is " + returnPage);
}
else if (item.isFormField() && item.getFieldName().equals("currentPath"))
{
final String previewStorePath =
AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath());
currentPath = AVMUtil.buildPath(previewStorePath,
item.getString(),
AVMUtil.PathRelation.WEBAPP_RELATIVE);
LOGGER.debug("currentPath is " + currentPath);
}
else
{
filename = FilenameUtils.getName(item.getName());
fileInputStream = item.getInputStream();
LOGGER.debug("uploading file " + filename);
}
}
LOGGER.debug("saving file " + filename + " to " + currentPath);
try
{
FileCopyUtils.copy(fileInputStream,
this.avmService.createFile(currentPath, filename));
final Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(1, 1.0f);
props.put(ContentModel.PROP_TITLE, new PropertyValue(DataTypeDefinition.TEXT, filename));
// props.put(ContentModel.PROP_DESCRIPTION,
// new PropertyValue(DataTypeDefinition.TEXT,
// "Uploaded for form " + this.xformsSession.getForm().getName()));
this.avmService.setNodeProperties(currentPath + "/" + filename, props);
this.avmService.addAspect(currentPath + "/" + filename, ContentModel.ASPECT_TITLED);
this.uploads.add(AVMNodeConverter.ToNodeRef(-1, currentPath + "/" + filename));
returnPage = returnPage.replace("${_FILE_TYPE_IMAGE}",
Utils.getFileTypeImage(facesContext, filename, true));
}
catch (Exception e)
{
LOGGER.debug(e.getMessage(), e);
returnPage = returnPage.replace("${_UPLOAD_ERROR}", e.getMessage());
}
LOGGER.debug("upload complete. sending response: " + returnPage);
final Document result = XMLUtil.newDocument();
final Element htmlEl = result.createElement("html");
result.appendChild(htmlEl);
final Element bodyEl = result.createElement("body");
htmlEl.appendChild(bodyEl);
final Element scriptEl = result.createElement("script");
bodyEl.appendChild(scriptEl);
scriptEl.setAttribute("type", "text/javascript");
final Node scriptText = result.createTextNode(returnPage);
scriptEl.appendChild(scriptText);
final ResponseWriter out = facesContext.getResponseWriter();
XMLUtil.print(result, out);
out.close();
}
private String getCurrentAVMPath()
{
AVMNode node = this.avmBrowseBean.getAvmActionNode();
if (node == null)
{
return this.avmBrowseBean.getCurrentPath();
}
final String result = node.getPath();
return node.isDirectory() ? result : AVMNodeConverter.SplitBase(result)[0];
}
}

View File

@@ -19,7 +19,8 @@
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" */
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.web.forms;
import java.io.Serializable;
@@ -45,7 +46,7 @@ public interface FormProcessor
{
/** Returns the set of file uploaded during the session. */
public NodeRef[] getUploadedFiles();
// public NodeRef[] getUploadedFiles();
/** Destroys the session and releases all resources used by it */
public void destroy();

View File

@@ -19,7 +19,8 @@
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" */
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.web.forms.xforms;
import java.io.*;
@@ -108,7 +109,7 @@ public class XFormsBean
private ChibaBean chibaBean;
private final Schema2XForms schema2XForms;
private final Set<NodeRef> uploads = new HashSet<NodeRef>();
// private final Set<NodeRef> uploads = new HashSet<NodeRef>();
private final List<XMLEvent> eventLog = new LinkedList<XMLEvent>();
public XFormsSession(final Document formInstanceData,
@@ -124,19 +125,8 @@ public class XFormsBean
baseUrl);
}
public void addUpload(final NodeRef nr)
{
this.uploads.add(nr);
}
public NodeRef[] getUploadedFiles()
{
return (NodeRef[])this.uploads.toArray(new NodeRef[0]);
}
public void destroy()
{
this.uploads.clear();
try
{
this.chibaBean.shutdown();
@@ -171,7 +161,6 @@ public class XFormsBean
private Schema2XFormsProperties schema2XFormsProperties;
private AVMBrowseBean avmBrowseBean;
private AVMService avmService;
private NodeService nodeService;
public XFormsBean()
{
@@ -443,171 +432,6 @@ public class XFormsBean
out.close();
}
/**
* Provides data for a file picker widget.
*/
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_XML)
public void getFilePickerData()
throws Exception
{
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ExternalContext externalContext = facesContext.getExternalContext();
final Map requestParameters = externalContext.getRequestParameterMap();
String currentPath = (String)requestParameters.get("currentPath");
if (currentPath == null)
{
currentPath = this.getCurrentAVMPath();
}
else
{
final String previewStorePath =
AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath());
currentPath = AVMUtil.buildPath(previewStorePath,
currentPath,
AVMUtil.PathRelation.WEBAPP_RELATIVE);
}
LOGGER.debug(this + ".getFilePickerData(" + currentPath + ")");
final Document result = XMLUtil.newDocument();
final Element filePickerDataElement = result.createElement("file-picker-data");
result.appendChild(filePickerDataElement);
final AVMNodeDescriptor currentNode = this.avmService.lookup(-1, currentPath);
if (currentNode == null)
{
final Element errorElement = result.createElement("error");
errorElement.appendChild(result.createTextNode("Path " + currentPath + " not found"));
filePickerDataElement.appendChild(errorElement);
currentPath = this.getCurrentAVMPath();
}
else if (! currentNode.isDirectory())
{
currentPath = AVMNodeConverter.SplitBase(currentPath)[0];
}
Element e = result.createElement("current-node");
e.setAttribute("avmPath", currentPath);
e.setAttribute("webappRelativePath",
AVMUtil.getWebappRelativePath(currentPath));
e.setAttribute("type", "directory");
e.setAttribute("image", "/images/icons/space_small.gif");
filePickerDataElement.appendChild(e);
for (Map.Entry<String, AVMNodeDescriptor> entry :
this.avmService.getDirectoryListing(-1, currentPath).entrySet())
{
e = result.createElement("child-node");
e.setAttribute("avmPath", entry.getValue().getPath());
e.setAttribute("webappRelativePath",
AVMUtil.getWebappRelativePath(entry.getValue().getPath()));
e.setAttribute("type", entry.getValue().isDirectory() ? "directory" : "file");
e.setAttribute("image", (entry.getValue().isDirectory()
? "/images/icons/space_small.gif"
: Utils.getFileTypeImage(facesContext,
entry.getValue().getName(),
true)));
filePickerDataElement.appendChild(e);
}
final ResponseWriter out = facesContext.getResponseWriter();
XMLUtil.print(result, out);
out.close();
}
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
public void uploadFile()
throws Exception
{
LOGGER.debug(this + ".uploadFile()");
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ExternalContext externalContext = facesContext.getExternalContext();
final HttpServletRequest request = (HttpServletRequest)
externalContext.getRequest();
final ServletFileUpload upload =
new ServletFileUpload(new DiskFileItemFactory());
upload.setHeaderEncoding("UTF-8");
final List<FileItem> fileItems = upload.parseRequest(request);
final FileUploadBean bean = new FileUploadBean();
String uploadId = null;
String currentPath = null;
String filename = null;
String returnPage = null;
InputStream fileInputStream = null;
for (FileItem item : fileItems)
{
LOGGER.debug("item = " + item);
if (item.isFormField() && item.getFieldName().equals("upload-id"))
{
uploadId = item.getString();
LOGGER.debug("uploadId is " + uploadId);
}
if (item.isFormField() && item.getFieldName().equals("return-page"))
{
returnPage = item.getString();
LOGGER.debug("returnPage is " + returnPage);
}
else if (item.isFormField() && item.getFieldName().equals("currentPath"))
{
final String previewStorePath =
AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath());
currentPath = AVMUtil.buildPath(previewStorePath,
item.getString(),
AVMUtil.PathRelation.WEBAPP_RELATIVE);
LOGGER.debug("currentPath is " + currentPath);
}
else
{
filename = FilenameUtils.getName(item.getName());
fileInputStream = item.getInputStream();
LOGGER.debug("uploading file " + filename);
}
}
LOGGER.debug("saving file " + filename + " to " + currentPath);
try
{
FileCopyUtils.copy(fileInputStream,
this.avmService.createFile(currentPath, filename));
final Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>(2, 1.0f);
props.put(ContentModel.PROP_TITLE, new PropertyValue(DataTypeDefinition.TEXT, filename));
props.put(ContentModel.PROP_DESCRIPTION,
new PropertyValue(DataTypeDefinition.TEXT,
"Uploaded for form " + this.xformsSession.getForm().getName()));
this.avmService.setNodeProperties(currentPath + "/" + filename, props);
this.avmService.addAspect(currentPath + "/" + filename, ContentModel.ASPECT_TITLED);
this.xformsSession.addUpload(AVMNodeConverter.ToNodeRef(-1, currentPath + "/" + filename));
returnPage = returnPage.replace("${_FILE_TYPE_IMAGE}",
Utils.getFileTypeImage(facesContext, filename, true));
}
catch (Exception e)
{
LOGGER.debug(e.getMessage(), e);
returnPage = returnPage.replace("${_UPLOAD_ERROR}", e.getMessage());
}
LOGGER.debug("upload complete. sending response: " + returnPage);
final Document result = XMLUtil.newDocument();
final Element htmlEl = result.createElement("html");
result.appendChild(htmlEl);
final Element bodyEl = result.createElement("body");
htmlEl.appendChild(bodyEl);
final Element scriptEl = result.createElement("script");
bodyEl.appendChild(scriptEl);
scriptEl.setAttribute("type", "text/javascript");
final Node scriptText = result.createTextNode(returnPage);
scriptEl.appendChild(scriptText);
final ResponseWriter out = facesContext.getResponseWriter();
XMLUtil.print(result, out);
out.close();
}
private void swapRepeatItems(final RepeatItem from,
final RepeatItem to)
throws XFormsException

View File

@@ -67,6 +67,7 @@ public class XFormsProcessor
"/scripts/ajax/dojo/" + (LOGGER.isDebugEnabled()
? "dojo.js.uncompressed.js"
: "dojo.js"),
"/scripts/ajax/common.js",
"/scripts/ajax/ajax_helper.js",
"/scripts/ajax/tiny_mce_wcm_extensions.js",
"/scripts/ajax/xforms.js",
@@ -79,12 +80,14 @@ public class XFormsProcessor
{
"add_content",
"cancel",
"change",
"click_to_edit",
"eg",
"go_up",
"idle",
"loading",
"path",
"select",
"upload",
"validation_provide_values_for_required_fields"
};