3 Replies Latest reply on Aug 30, 2009 3:37 AM by rashmi_ceru ceru

    Tomahawk File Upload

    Angelo D'Angelo Newbie

      Hi all, I have to create a jsf portlet for file uploading, but I am not able to use inputFileUpload (Apache Tomahawk). It seems that it does not work inside a portlet. Do you know if there is a workaround for this issue, or if there are other JSF extensions that provide this kind of feature? Thanks.

        • 1. Re: Tomahawk File Upload
          Sohil Shah Master


          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()});
           //process the FileItem here....this is your attachment


          • 2. Re: Tomahawk File Upload
            Angelo D'Angelo Newbie

            Hi Sohil (thanks for the answer),
            but any existing Portal/Portlets Bridge lets me able to use Tomahawk?


            • 3. Re: Tomahawk File Upload
              rashmi_ceru ceru Newbie

              Hi ,

              when we are trying to set the values to requestparameter map i am getting exception

              Caused by: java.lang.UnsupportedOperationException
              at java.util.Collections$UnmodifiableMap.put(Collections.java:1286)
              ... 197 more

              i am using org.apache.myfaces.component.html.util.ExtensionsFilter as filter .
              can any you please let me know how to solve this problem .

              this is place where i am getting exception .
              req.getParameterMap().put(item.getFieldName(), new String[]{item.getString()});