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

Similar Messages

  • How to store and retriew .pdf or .doc using file uploader component

    hi,
    I want to store a .pdf / .doc file in the database and retiew it. I am using
    sun studio enterprise for EJB developing(sun application server as the container) , Oracel as DBMS and sun studio creator for frontend.
    kaushalya

    public String saveButton_action ()
            // TODO: Process the button click action. Return value is a navigation
            // case name where null will return to the same page.
            tagsDataProvider1.cursorLast ();
            //UploadedFile f = fileUpload1.getUploadedFile ();
            if (fileUpload1.getUploadedFile ()!=null)
                tagsDataProvider1.setValue ("attachment",fileUpload1.getUploadedFile().getBytes ());
                tagsDataProvider1.setValue ("attachmentfilename",fileUpload1.getUploadedFile().getOriginalName ());
                tagsDataProvider1.setValue ("attachmentcontenttype",fileUpload1.getUploadedFile().getContentType ());
            tagsDataProvider1.commitChanges ();
            return "home";
        }This servlet returns the data to the user unadulterated:
    * FileView.java
    * Created on October 6, 2005, 4:50 PM
    * To change this template, choose Tools | Options and locate the template under
    * the Source Creation and Management node. Right-click the template and choose
    * Open. You can then make changes to the template in the Source Editor.
    package docman;
    * @author USER
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.DataSource;
    public class FileView  extends HttpServlet {
    String ct;
    String type;
        /** Creates a new instance of DisplayPicture */
        public FileView() {
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        public void destroy() {
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            String id=request.getParameter("id");
            type=request.getParameter("type");
            //String ct=request.getParameter("contenttype");
            //if ((ct==null)||(ct.equals(""))) {
                //ct="image/x-jpeg";
                //ct="image/bmp";
            System.out.println("FileView 1.0");
            System.out.println("requested file with ID: "+id+" content: "+ct+" Doctype:"+type);
            try {
                ServletOutputStream out = response.getOutputStream();
                byte[] f=this.getImage(id);
                response.setContentType(ct);
                out.write(f);
            } catch (Exception e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
        /** Handles the HTTP <code>GET</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        /** Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        /** Returns a short description of the servlet.
        public String getServletInfo() {
            return "Displays a picture from the database identified by a parameter IMAGEID";
        private byte[] getImage(String id) throws IOException {
            Statement sta=null;
            Connection con=null;
            ResultSet rs=null;
            byte[] result=null;
            try {
                Context initContext = new InitialContext();
                Context envCtx = (Context) initContext.lookup("java:comp/env");
                DataSource ds = null;
                try{
                     ds = (DataSource)envCtx.lookup("jdbc/xxxxx");
                }catch ( javax.naming.NameNotFoundException ex){
                    log("No context found for jdbc/xxxxx in java:comp/env Attempting to look it up in initial context");
                    ds = (DataSource)initContext.lookup("jdbc/xxxxx");
                Connection conn = ds.getConnection();
                sta = conn.createStatement();
                if(type==null){rs=sta.executeQuery("SELECT * FROM tags where tagid="+id);}
                else if (type.toLowerCase ().equals("tag")){rs=sta.executeQuery("SELECT * FROM tags where tagid="+id);}
                else if (type.toLowerCase ().equals("crewdoc")){rs=sta.executeQuery("SELECT * FROM crewdocumentation where docid="+id);}
                if (rs.next()) {
                    result=rs.getBytes("attachment");
                    ct=rs.getString ("attachmentcontenttype");
                    System.out.println("bytes returned : "+result.length);
                } else {
                    System.out.println("Could find image with the ID specified or there is a problem with the database connection");
                rs.close();
                sta.close();
                conn.close();
            } catch (Exception e) {
                log(e.getMessage());
                e.printStackTrace();
           // ByteArrayOutputStream output = new ByteArrayOutputStream();
            //output.write(result, 78, result.length-78);
            //output.flush();
            //output.close();
            //return output.toByteArray();
            return result;
    }I pinched both from examples i found on this forum using the search facility...
    And this hyperlink retreives the file:
    <ui:hyperlink binding="#{TagView.tagHyperlink}" id="tagHyperlink"
                                        text="#{TagView.tagsDataProvider.value['tags.attachmentfilename']}" url="/servlet/FileView/?id=%23%7BTagView.tagsDataProvider.value%5B'tags.tagid'%5D%7D+"&"+#{TagView.tagsDataProvider.value['tags.attachmentfilename']}"/>

  • How to use flex 4 component inside Flex 3 custom component

    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"   >
    // I would like to use the namespaces below so that I can use some of the Flex 4 components in this mx:VBox component.
    // Note that this is a custom component and not the application file.
    xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:fx="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/halo"
    </mx:VBox>
    Thanks.

    Alex, I was looking forward to your reply to one of my posts that you answered a couple of days ago. It has not been resolved, even though it said "answered," here is the post:
    http://forums.adobe.com/thread/445779?tstart=0
    Regarding this post, I am getting some errors with the code I posted above; give it a go and you will see.
    Thanks.

  • Screen hangs when user types in some text in file upload component

    Dear All
    I am using file upload component in webdynpro java in a custom application and added some validation logic on the file
    selected. This is being used to upload jpeg files to KM repository. Now the issue is if user types some text in the file
    upload input field and click on upload button the screen hangs and it goes to infinite loop. It seems that the framework is not able to accept and check the arbitrary value entered by user.
    Can anyone tell me how this can be sorted out?
    Thanks
    Sudip

    Hello Sudeep,
    I have also faced the same issue and to me it seems an issue with the UI element itself. Please follow the following threads for more information:
    [http://help.sap.com/saphelp_nw04s/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm]
    and
    [File Upload UI Element going in Infinite loop;
    [upload UI element;
    Hope this may be of some use.
    Regards,
    Gaurav

  • 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

  • Problems getting just the file name using an upload component

    Hi everyone, I'm using an upload component on my page and I need to get just the name of the image/file in order to store it in a database, I used the code of the tutorial and It works fine on mozilla but the problem comes when I use Internet Explorer because I get the whole path of the image/file and not just the name of it. I believe the browser is the cause of the problem, I already checked the http://jakarta.apache.org/commons/fileupload/, but I don't understand how to use anything, and not even the code of the tutorial works eventhough it is specified in comments:
    // some browsers return complete path name, some don't
       // make sure we only have the file name
       String justFileName = uploadedFileName.substring
          ( uploadedFileName.lastIndexOf(File.separatorChar) + 1 );If anybody could helpme solve this problem I'd appreciate it so much
    Regards
    Yes
    Message was edited by:
    Yesenia

    Let's walk through the code...
    File.separatorChar is the system-dependent default hame-separator charac tor. This field is initialized to contain the first character of the system property file.separator. On UNIX systems, the value of this field is '/'; on Microsoft Windows systems it is '\\'.
    String justFileName =
    // get the substring of uploadedFileName
    // that starts after the last separator (\ or /)
    uploadedFileName.substring
    uploadedFileName.lastIndexOf(File.separatorChar) + 1
    You say that this statement is returning the complete path name, for example:
    C:\Documents and Settings\All
    Users\Documentos\Mis im��genes\Im��genes de
    muestra\Puesta de sol.jpgSo, we can make an assumption that the File.separatorChar must not be \, or else the statement would return Puesta de sol.jpg.
    We know that it works for you on Solaris/Mozilla.
    We also know that Misha has tested the statement in IE and it works for him.
    (And I know that this tutorial was tested by a software engineer and a quality engineer, and it worked for both of them, as well as the tutorial author and a peer).
    So, what is different here??????
    Can you print out File.separatorChar and see if it is '\\' (I think the first \ is an escape char, that is \\ (escape-escape) is the equivalent of \ (backslash)) or '\'?
    When you run it on another machine, how are you deploying it on the other machine? Is it deployed to Solaris and running on Windows?
    Have you tested to see if it works on a Windows machine using Mozilla?
    Thanks in advance for any light you can shed on the problem.

  • 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

  • File upload component in JStudio Enterprise

    Dear all,
    I am not sure that File Upload Component is supported in JStudio Enterprise 8.1 or not. I see that Netbeans has one: http://www.netbeans.org/kb/55/vwp-about_components.html.
    So I thought JStudio Enterprise may have one similar. If so, can anyone tell me how to do that please?
    Regards,
    Kai

    FileUpload component is not supported in Java Studio Enterprise. The FileUpload is a component that conforms to the spec recognized by Java Studio Creator line of products (which is now Visual Web Pack) and will not work in JSE.
    You can use NetBeans 5.5 and install Visual web pack (for javafaces support), enterprise pack (which provides all capabilities of JSE) and uml on top of it. It would give you a single install with all add-ons.

  • File upload component and text area issue

    Hi guys,
    I have static text, text area and button on the same page. Text area binded to session bean value and all works fine (I can input text into text area and press button to save changes).
    After adding file upload component to the same page I have got a problem - now after page refreshing the non english characters inside text gets trashed.
    Other non english characters - inside static text components remains the same - the problem relates only to text area.
    It looks like file upload component code has an encoding related bug. Is that a known issue?
    And may be somebody have a workaround?
    Thanks.

    Hi Rom@n,
    I did some checking and this issue is currently logged as: 6442528. It is scheduled to be available in the next patch release. I'm sorry I don't have a time frame for the patch since it is still waiting for other fixes.
    Sorry for the inconvience.
    Lark
    Creator Team

  • Hot to call processValueChange() method of the file upload component?

    When the value changes (when I choose a new file to upload) in the file upload component the processValueChange() method is not called.
    I am planing to show the preview of the image to be uploaded using the processValueChange().
    Thanks.

    Is there a bug connected with this issue?
    Thanks.

  • Htmlb table - File upload component

    Hi all,
    Is it possible to use the file upload component in a table view (htmlb for java) column?
    Rgds,
    Subu

    Hi,
    Here is one thought, there is onCellClick event for the Tableview, use that for the required column and add the file upload component as the event handler method in the onCellClick method.
    Link on table view events:
    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/eb/220a415a47f06fe10000000a1550b0/content.htm">Table view attributes and events</a>
    Link on OnCellClick:
    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/37/3d8b41b4b3b25fe10000000a1550b0/content.htm">onCellClick</a>
    Check the following link:
    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/63/9c0e41a346ef6fe10000000a1550b0/frameset.htm">File upload</a>
    Hope it helps.
    Regards,
    Vivekanadan
    Message was edited by: Vivekanandan

  • Myfaces's file upload component

    I used the myfaces's file upload component in my web application. But this component needs to set the form's enctype attribute to "multipart/form-data". But after I have set this attribute, my other components in the form seemed doesn't work anymore. Is there any way to solve this problem? Thank you

    Some people seem to be running into this. Doing these steps should fix the problem:
    Right click the component library node "Basic" and choose "Manage Component Libraries". That opens the Component Library Manager window. Verify that the "On Palette" property is checked for "File Upload".
    Hope it helps,
    Lark

  • 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

  • How to use File Adapter with hierarchial Structure?

    Hi,
    How to use File Adapter with hierarchial Structure like..
    Data:
    --Header Details:
    Line Item Details:
    Data
    Bcoz I am getting a Flatfile in a hierarchial way as shown below.
    Header Details :1
    Line Item a
    Line Item b
    Header Details :2
    Line Item c
    Line Item d
    Kishore

    Hey Kishore,
    In order to create a structure you need to use the file with convertion mode on the sending communication channel of the file adapter.
    check the link for the needed configuration paramters.
    If the structure is more complexed you can use the Contetnt master(CM) from itemfield which allows to ceate XML file from complex flat files and more.
    <a href="http://help.sap.com/saphelp_erp2005/helpdata/en/0d/5ab43b274a960de10000000a114084/frameset.htm">File sender adapter</a>
    If you have any question i'll be more than happy to assist.
    Nimrod Gisis

  • How to use File Adapter in BPEL

    Hi,
    How to use File Adapter in BPEL. I am using Oracle SOA 10g. Any sample or best example in blog or elsewhere ?

    Hi,
    Please check the below links for samples on how to use file adapter in BPEL (in 10g/11g usage is same) and let me know any further queries.
    11g - http://blogs.oracle.com/theshortenspot/entry/soa_suite_integration_part_3_l
    10g - http://erpschools.com/articles/bpel-file-adapter-tutorial

Maybe you are looking for