[jboss-user] [JBoss Portal] - Re: Tomahawk File Upload
sohil.shah@jboss.com
do-not-reply at jboss.com
Fri Jul 28 09:34:12 EDT 2006
Angelo-
You are right. The JSF approach does not work in the portal environment. Try the org.apache.commons.fileupload.portlet.PortletFileUpload approach in your portlet. Here is some sample code to get you started
| import org.apache.commons.fileupload.FileItem;
| import org.apache.commons.fileupload.disk.DiskFileItemFactory;
| import org.apache.commons.fileupload.portlet.PortletFileUpload;
|
|
| /**
| *
| *
| */
| private void processAttachments(ActionRequest req) throws Exception
| {
| DiskFileItemFactory factory = new DiskFileItemFactory();
| PortletFileUpload upload = new PortletFileUpload(factory);
|
| //Merge with upload fields
| for (Iterator i = upload.parseRequest(req).iterator(); i.hasNext();)
| {
| FileItem item = (FileItem)i.next();
| if (item.isFormField())
| {
| //if it's form field just add it to request params map
| //TODO:Be aware that this adds single value as we won't have multiply values in new topic form for now...
| req.getParameterMap().put(item.getFieldName(), new String[]{item.getString()});
| }
| else
| {
| //process the FileItem here....this is your attachment
| //data
| }
| }
| }
|
Thanks
Sohil
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961554#3961554
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961554
More information about the jboss-user
mailing list