Problem using File upload in portlets

hello there
I'm trying to use file upload component in one of my portlets. I searched a lot about a working component to be used in portlets since the standard one that comes with JSC doesn't work in portlets. I managed to get commons file upload and tomahawk to run in my portlet, but when I choose a file and try to get selected file's details it throughs a NullPointerException reporting that the file object is null.
so please can anyone guide me to a working portlet example, I tried to find one but I couldn't. if that's hard to find, what should I do ?
thank you in advance

I added file upload component in JSF from portlets in Sun Java Portal server.
Take a look...
portlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
<portlet>
<description>SFTB Anonymous Mail Portlet</description>
<portlet-name>SFTBAnonymousMailPortlet</portlet-name>
<display-name>SFTBAnonymousMailPortlet</display-name>
<portlet-class>org.apache.portals.bridges.portletfilter.FilterPortlet</portlet-class>
<init-param>
<name>portlet-class</name>
<value>com.sun.faces.portlet.FacesPortlet</value>
</init-param>
<!-- Filter for MyFaces Tomahawk extension. -->
<init-param>
<name>portlet-filters</name>
<value>jp.sf.pal.tomahawk.filter.ExtensionsPortletFilter</value>
</init-param>
<init-param>
<description>Portlet init page</description>
<name>com.sun.faces.portlet.INIT_VIEW</name>
<value>/jsp/index.jsp</value>
</init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
<portlet-mode>EDIT</portlet-mode>
<portlet-mode>HELP</portlet-mode>
</supports>
<portlet-info>
<title>&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1082;&#1072; &#1087;&#1088;&#1077;&#1076;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1081;</title>
<short-title>&#1054;&#1090;&#1087;&#1088;&#1072;&#1074;&#1082;&#1072; &#1087;&#1088;&#1077;&#1076;&#1083;&#1086;&#1078;&#1077;&#1085;&#1080;&#1081;</short-title>
</portlet-info>
</portlet>
</portlet-app>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>SFTBAnonymousMailComment</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<!--
Extensions filter from Apache MyFaces Tomahawk used for uploads files.
-->
<filter>
<filter-name>ExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>10m</param-value>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
</description>
</init-param>
<init-param>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
</description>
</init-param>
</filter>
<filter-mapping>
<filter-name>ExtensionsFilter</filter-name>
<servlet-name>FacesServlet</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
Files in WEB-INF/lib
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-fileupload-1.2.1.jar
commons-io-1.2.jar
commons-logging-1.1.1.jar
faces-response-filter-0.2.jar
jsf-api-1.1_02.jar
jsf-impl-1.1_02.jar
jsf-portlet-1.1.5.jar
jstl-1.1.0-D13.jar
log4j-1.2.9.jar
portals-bridges-portletfilter-1.0.jar
standard-1.1.0-D13.jar
tomahawk-1.1.6.jar
tomahawk-bridge-0.9.1.jar
Files tomahawk-bridge-0.9.1.jar, faces-response-filter-0.2.jar may be found there http://sourceforge.jp/projects/pal/
In JSF beans I'm using org.apache.myfaces.custom.fileupload.UploadedFile
Hope this helps.
Bests,
Alex Magdenko

Similar Messages

  • Problem with File Uploading.

    Hi,
    I have one problem with File Upload component.
    JSP
    <ui:upload binding="#{NewProblem.fileUpload1}" columns="#{SessionBean1.uploadedFile}" id="fileUpload1" labelLevel="3"
    style="left: 24px; top: 24px; position: absolute" validator="#{NewProblem.fileUpload1_validate}"/>
    Java
    UploadedFile uploadedFile = getSessionBean1().getUploadedFile();
    Variable uploadedFile is NULL :(((((((((((
    web.xml
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
    </context-param>
    <filter>
    <filter-name>UploadFilter</filter-name>
    <filter-class>com.sun.web.ui.util.UploadFilter</filter-class>
    <init-param>
    <param-name>maxSize</param-name>
    <param-value>10000000</param-value>
    </init-param>
    <init-param>
    <param-name>sizeThreshold</param-name>
    <param-value>10024</param-value>
    </init-param>
    </filter>
    Thanks.

    check out the fileUpload article
    Using the File Upload Component
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/file_upload.html

  • Newbie : memory problem with file uploading

    Hello
    I'm exdending a web app based on jsf and , being new to it and java in general, i'm having a problem with file uploading.
    The customer needs to upload large file (more than 30 MB). The application accomplish this using a fileupload component, to let the user select the file, and passing the array of bytes to a web service method.
    I'm using netbeans 6, tomcat 5.5.
    When i try to upload a file too large i got an outofmemory on the local tomcat. So i've rised jvm memory and going on with tests i've found that growing the size i got an http 500 error from the service (the developer of the service has found an out of memory too ).
    I think the service is not modifiable, so i were asking if threre were a way to optimize the file uploading process (a component, a library, a pattern ...) or my only chioice is to rise available memory on both sides.
    I've notice the wsdl declares as base64binary type the data parameter , while netbeans 6 generates a client proxy with a byte[] parameter. Is correct or is a netbeans problem?
    searching with google i've found few thing i haven't fully understood due to my lack of experience:
    the mtom , how can evaluate if it's suitable to help in my problem (i suppose it involves more the web service rather than the client)
    something about the size of a soap body.
    thank you in advance
    Stefano

    Which component exactly are you using? Declaring the stream as a raw byte[] is certainly not efficient. Write code yourself, don't let it autogenerate.
    I can highly recommend you the Tomahawk t:inputFileUpload component. It is easy to integrate in Mojarra. You can find here an useful article: [http://balusc.blogspot.com/2008/02/uploading-files-with-jsf.html].

  • Problem using File sharing  in a small office network

    I have a problem using File sharing on an Imac and Macbook Pro.
    My office has a small network running Windows Small office file server 2003. I have one Windows 2000 PC connected to it and 3 Macs, an 2.4 gHz Intel iMac running Leopard 10.5.6 , a MBP running the same and a Mac Mini running 10.5.
    From the Finder Shared window of the Mac Mini, I can see all the computers on the network. It also used to be the case for the iMac, but the MBP could never see the Windows PC’s, not the server or the Win2000. This wasn’t a big problem as I was communicating between the Macs and using the shared printer on the iMac.
    On Monday Jan 19 the iMac was suddenly unavailable to the other 2 Macs. It was working normally on the Friday. The iMac can access the Mac Mini and copy files to it. The Mac Mini can see the iMac but cannot access it. Even trying to connect as, ends in a failed connection. I have tried rebooting, turning File sharing off and then on again to no avail.
    The iMac now also cannot see the Windows PC’s which it previously could.
    To get files from the MBP for printing, I now copy it to the Mac Mini and acces the folder from the iMac, a very tedious procedure. I don’t know why this happened and am scared that the Mac Mini is going to do the same thing.
    All three computers are also running VMware 2.0 with Windows XP pro, and from VMware the server is visible on all the computers.
    Any help will be much appreciated, I live in a small town in South Africa and the local computer suppliers have no knowledge of the Macs.
    I think that the problem with the iMac may have started after a software upgrade to 10.5.6 but I am not entirely sure.
    Thank you
    ajdk

    Well, you're current method sounds pretty good. But if you want to user a file server, hey go ahead.
    What you want to do when you centralize project files is to keep track of which one is the newest and becareful not to overwrite files with the same name. So you either have to set up individual spaces on the server (separate AFP/FTP folders maybe), or you'll need to run a file checkout service.
    The individual space is cheaper, but it's not much of a difference from backing up to the network drive. Since you have Gigabit connections, you might even opt to save ALL the user files on the server instead of just the project files.
    If you want to run a file checkout service, there's two approaches. You can run a service that can host any kind of file, or you can run a version control system for each kind of application (Photoshop, Word, etc.). Please notice, that as you read further and further along, the methods become more and more expensive and complicated. Once you get to this point, it will be necessary to purchase or build software in addition to the Mac OS X Server package.

  • Upload file without using file upload UI Element

    Hi all.
    I need upload a .txt file without using file upload UI Element because filename is not insert by user. The filename is generated by program. I try to use 'GUI_UPLOAD' and 'WS_UPLOAD' but don't work.
    Many thanks in advance.

    As you correctly pointed out we cannot use the gui_upload and gui_download fm's in webdynpro because they require sap gui and WD Components generally run in a HTML or Portal environment.
    The only option available is File Upload Element

  • Problem in file upload......

    hi
    i had problem in file upload to server.
    i gave a absolute path to stored location that is working.
    but i tried to give relative path of the server that is not working
    plz help me to this problem..
    how to give relative path to Tomcat server...

    FilePart filePart = (FilePart) part;
              String fileName = filePart.getFileName();
              if (fileName != null) {
                   // the part actually contained a file
    String path= getServletContext().getRealPath("/empimages");
    File dir = new File(path);
                   long size = filePart.writeTo(dir);
                   }

  • How to upload multiple files in Webdynpro using File upload Screen Element

    Hi Experts,
          Can anybody tell me how to upload multiple files/pdfs in webdynpro using file upload screen element, and also please tell me what is the maximum storage limit of RAWSTRING data type,Advance Thanks.
    Regards,
    Sandesh

    Hi Sandesh,
    this is simply not supported, not in WebDynpro nor in standard HTML.
    A workaround is to upload a ZIP with all files and on server side unpack the ZIP and operate on the single files.
    I hope it will  help u..
    ----------------------OR-------------------------
    As you know using File upload UI element we can upload only one file at a time. There may be a scenario where user may want to upload any no of files at a time which is not determined at design time. This can be acheived using the ACF UpDownload UI element which requires a security whiltelist to be created
    http://scn.sap.com/docs/DOC-2270
    ----------------------OR-------------------------
    You can use Table UI element.
    Regards,
    Deepak Singh

  • I need to select and upload a image and corresponding url from an external website using file upload control in MVC4. Please help

    I need to select and upload a image and corresponding  url from an external website using file upload control in MVC4.
    Please help
    Latheesh K Contact No:+91-9747369936

    This forum supports .NET Framework setup.
    As your issue appears to have nothing to do with .NET Framework setup, please ask in the MVC forums for best support.
    http://forums.asp.net/1146.aspx/1?MVC

  • How to use file upload component inside a portlet

    Hi
    Thank you for reading my post.
    does file upload works inside portlets ?
    can some one help me with a sample code , does it need some tricks ?
    Thank you

    any help is welcomeLegolas,
    You could try your own implementation. Someone was able to implement a file upload with Creator 2004Q4 and the O'Reilly Servlet. See http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=50186.
    You will have to configure O'Reilly Servlet's "MultiPart Filter" in your application. Creator 2 uses a same approach (a filter) to accomplish this. Given that the file upload component is not supported on portlets, this leads me to the following: I don't know anything about portlets and portlet containers, but I'd check first for some architechtural restriction in the portlet subsystem that avoids the use of a filter for a file upload. If think this could be the only thing that will restrict you to implement your own file upload.
    Hope this helps.
    Antonio

  • Problems with file upload using AMF or SOAP

    We use your AMF to connect Flex with Ruby on Rails.
    Everything is OK, except file upload.
    We did not find how to upload file using AMF or SOAP RPC from
    Flex. Only to use FileReference.upload().
    The problem is that Flex uses different User-Agent in HTTP
    header for this upload and for SOAP/AMF calls.
    This means that sessions are different. And even if you
    authenticated via SOAP/AMF you can not use it to upload file.
    Could you, please, advice is there any other way to upload
    files from Flex via SOAP or AMF?

    Please, help me on this issue, i am still waiting for someone replying me!

  • Problem with file upload

    Hi all, my problem has something to do with internal working of pageflow.
    Here is what has happened:
    1. I have a page with a few portlets on it.
    2. One of the portlet is for uploading file (lets call it upload portlet)
    3. The rest of the portlet need to access the PortletBackingContext using the following code (put in a jpf):
    PortletBackingContext portletCtx = PortletBackingContext.getPortletBackingContext(super.getRequest());
    4. When the upload portlet transfers the file, the other portlets will refresh (i'm using refreshAction attribute).When the other portlets refresh, they can't get the PortletBackingContext. It always returns null.
    If I remove the enctype="multipart/form-data" from the netui:form tag, it works as per normal (but of course the file uploading fails).
    Any idea?
    Thanks.
    panji.a
    [att1.html]

    This post may be useful:
    http://forums.bea.com/bea/message.jspa?messageID=600021968&tstart=0

  • Threading problem during File Upload with Apache faces upload tag

    First I am going to tell you "My Understanding of how JSF Apache Upload works, Correct me if i am wrong".
    1) Restores View (to show Input box and Browse button to facilitate users to select a file for upload)
    2) Translates Request Parameters to Component Values (Creates equivalent components to update them with request values).
    3) Validates Input(Checks to see whether the User has input the correct file)
    4) Updates Backing Bean or Model to reflect the values.
    5) Renders response to user.
    I am uploading huge files of sizes 400MB and above with the help of JSF apache extensions tag
    <h:form id="uploadForm" enctype="multipart/form-data">
    <x:inputFileUpload style="height:20px;" id="upload" value="#{backingbean.fileContents}" storage="file" size="50" />
    </h:form>
    In the backing bean
    private UploadedFile fileContents;
         public UploadedFile getFileContents() {
              return fileContents;
         public void setFileContents(UploadedFile fileContents) {
              System.out.println("File being uploaded...");
              this.fileContents = fileContents;
    Since, the file size is so huge, I am using temp folder to use for the apache tag instead of memory.
    In web.xml i am using like this
    <filter>
    <filter-name>ExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
    <init-param>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>600m</param-value>
    </init-param>
    <init-param>
    <param-name>uploadThresholdSize</param-name>
    <param-value>10m</param-value>
    </init-param>
         <init-param>
    <param-name>uploadRepositoryPath</param-name>
    <param-value>/uploadfolder/</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>ExtensionsFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    The upload process is working perfectly fine.
    Now coming to the problem:
    Suppose one user is logging into the application & uploading say 400MB of files.
    Until these files are linked to the model objects as my understanding of step 2, if second user tries to open the application he gets stuck with the loading page.
    The page gets loaded only after the request files are linked to the component values(Step 2 above) and updates the backing bean's values.
    I don't see any error in the logs. User is getting stuck. The user is getting stuck only when uploading the files. The other operations like searching are not blocking any other activities performed by the user.
    Server used: IBM Application Server V6.0. CPU is normal, memory usage is normal.

    Dear friend,
    i am also trying to upload using the common file upload.
    when try to run the file error is coming
    can give some suggestion.
    can i use if concurrent user file upload at a time

  • File Upload in Web Dynpro ABAP not using File Upload UI element

    Hi all ,
    I have searching for a way to upload a file using the file open dialog ( or even by manually specifying the path/file name) without using the file upload UI Element in ABAP web Dynpro . The  File Upload UI element works for smaller files however with large file sizes 64 MB , the system seems to be running of memory (SYSTEM_NO_ROLL) . This is due to a known fact that the UI element makes a duplicate copy of the whole copy while it does the upload.
    I have been looking at the ACFUPDOWNLOAD as a way to solve this problem but cannot seem to figure out how it works , even the sample program  provided  by SAP does not work. I am working with a regular abap server and not kpro( knowledge mananagement provider)  or portal .
    Any help would be greatly appreciated.
    thanks,
    Ali.

    If you are on NetWeaver 7.01, you can try both the ACFUpDownload UI element or try creating your own FileUpload in Adobe Flex with Flash Islands.  ACFUpDownload requires the KPRO by default (which is why the same application isn't working for you), but you can write your own handler class to act as the KPRO receiver.  Here is an eLearning on the topic:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/109b9b52-bc00-2c10-8786-e4c5e96d7e04
    and source code:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70645070-bb00-2c10-f086-f126721acdb4
    If you want an eLearning on the FlashIslands approach, you can find it here as well:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50d42644-91ef-2b10-228c-9e0ae75b274e
    and Source Code:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f044b62c-90ef-2b10-64a6-9ec25294d133
    However in both of these approaches you still have to be careful with how you handle large files.  The problem is that they are processed often a single binary string.  This makes the processing easy, but requires total amount of session memory at least as large as the file being uploaded.  In NetWeaver 7.02 ABAP adds the concept of Streams and Locators to help with the partial processing of large files.  This feature doesn't come until later this year, but if you are interested you can learn about it here:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80f983df-213e-2c10-ba89-b5a12ef178e8

  • Facing problem during file upload

    hi
    we r designing a portal where it is required to upload files based on individual users who have logged in.
    For this purpose we r using a file field in one page and http upload tag in another page.
    The file uploads successfuly to the database, but the problem is that we r not able to get the value of pReq.getUser() in the page where the httpfileupload tag exists.
    we noted that request.getParameter() and session.getValue() is also not valid in this page.
    we also tried setting the session value to true in provider.xml. Even this didnt work.
    we noted that this problem comes only when the file field is used. can anyone tell me how to solve this??
    Thanks in advance.
    voyager

    request.getParameter() nor session.getParameter() does not fetch anything. the value is null
    Regards,
    voyager

  • Problem with File Uploads

    Hello all. Has anybody successfully got the UploadFilter classes -- as listed in Hortsmann and Geary's "Core JSF" -- going?
    Everytime I submit a multipart form, I am not redirected to the appropriate next page (as specified in the navigation cases) . I have definitely set up the UploadFilter correctly, and any multipart form requests are getting parsed and uploaded into the correct directory. The only problem is that the resulting page isn't the one specified in faces-config.xml -- it's the original upload page.
    If I get rid of the multipart/form-data encoding for the form, it works "okay" (in the sense that the file upload no longer works, but the behaviour matches the navigation cases).
    I'm beginning to wonder whether the fact the form is a multipart form means that the submit button's action -- which is set to "submit", matching a value in faces-config.xml -- isn't being correctly parsed. Are there any "gotchas" I should be aware of in these cirumstances?

    Hi diritchie,
    perhaps that thread helps you.
    http://forum.java.sun.com/thread.jsp?forum=427&thread=473135
    There are posts of some clazzes, to enable upload.
    the clazzes are using Jakarta Commons FileUpload
    btw. in MyFaces there is allready an upload-component.
    Regards,
    Matthias

Maybe you are looking for

  • HP Color Laserjet 1600 cannot print in color with Pages 09

    Hi, everybody! I got a huge problem for me that the HP Color Laserjet 1600 cannot print in color with Pages 09 after I upgrade to 10.6.1. It worked very well in 10.5.8. Since there is no official driver from HP website for 1600, so I used foomatic/fo

  • Dual Monitors on Mac Mini Late 2014 not working on Dell S2340Lc

    Hey guys, Got a mac mini and using it mainly for work. Working for an ISP and no one has used macs and I've opted to be the poor sucker that gets to deal with old people that don't know how to mac very goodly. I have two Dell S2340Lc monitors. I have

  • Best approach for IDOC - JDBC scenario

    Hi, In my scenarion I am creating sales order(ORDERS04) in R/3 system and which need to be replicated in a SQL Server system. I am sending the order to XI as an IDoc and want to use JDBC for sending data to SQL Server. I need to insert data in two ta

  • Lost Faces on iPhoto

    In this case i lost 18300+ faces ? Need to know why befor i pull any more hair out. iPad 1st, Mac Mini and iPhone 4s I put my iPad 2nd in airport mode so the faces are still there!

  • Driving crazy with Time Capsule

    Hi Guys I am Apple user (macbook pro, iphone, ipod, ipad and now time capsule) I just bought a TC 2GB recently and is driving me crazy... I have a problem at the moment, i have my current internet router on my living room, and on my room my internet