File Uploading in JSF

I am facing problem with File Uploding. :(( Could you please provide me some pointers for this.
If possible detailed example is good for me as I am new to JSF
I know how to use Jakartas File Upload Component. Can you provide me some pointers regarding this in JSF.
Thanks
Sudhakar

I appretiate if you could point me out to the location of file upload component in the JSC. I know how to do it in servlets - just parse mime-multipart stream, but have no idea how to implement file upload/download in the JSC.
Thank you for your help!

Similar Messages

  • Error while during file upload in JSF

    Hi
    I do get this error while uploading a file in JSF .
    org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:134)
         at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:163)
         at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:157)
         at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:673)
         at jsf.PagePhaseListener.afterPhase(PagePhaseListener.java:18)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:211)
    Can anybody wat i must do

    thanks....
    but that answer is not solve my question. Actually i want to know.. can we develope a custom tag in JSF for file upload......

  • File Upload problem: JSF, IBM WPS and Portlet - Please HELP Vey Very Urgent

    I want to upload a file from the front end using JSF and Portlets deployed on IBM WebSphere Portal.
    I have used Apache's commons file upload functionality as the file upload provided in JSF doesnot work with portlets and the action event is not invoked If I keep enctype="multipart/form-data". So I included 3 forms in my Faces JSP file.
    1) h:form = For displyign error message on screen
    2) html:form = Include the enctype="multipart/form-data" and the input type file for uploading. And a submit button
    3) h:form: Here I have a command link which is remotely excuted on click of sumit button in my html form. This is to invoke the action event in the pagecode to get the bean value from the context.
    Now in the my doView method in the portlet, isMultipartContent(httpservletrequest) always returns null as the content type is text/html and not multipart. Onclick of the submit button in the the html form I am calling a javascript function which sets the __LINK_TARGET__ to the command link in the 3rd h:form which will call the page code.
    The problem here is action is invoked only when I return false from the above javascript else it will trigger for the first time and from second time onwards it will not invoke the action event in the pagecode method. Whent the javascript function returns false, the content type is always text/html. However if I return "true" from the javascript the content type is multipart/form-data, but the action is not triggered for the second time. So basically when the javascript functions returns true, for the first click everything works perfectly. When it returns false, the content type is text/html, but the action is invoked in the page code every time.
    Returning always true would solve my problem with the content type, but the action with the command link will not get invoked always as its some type of problem with h:commanLink :(.
    I guess I gave too much info. Heres my code stepby step.
    Can somebody please tell me , how I should also invoke the action in the page code and get the content type as "multipart/form-data" at the same time.
    1:
    ======================= Faces JSP File: BPSMacro.jsp ====================
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <meta name="GENERATOR" content="IBM Software Development Platform">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="/WEB-INF/tld/j4j.tld" prefix="j4j"%>
    <%@taglib uri="/WEB-INF/tld/core.tld" prefix="core"%>
    <%@page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1" session="false"%>
    <portlet:defineObjects />
    <link rel="stylesheet" type="text/css"
         href='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/theme/stylesheet.css") %>'
         title="Style">
    <script type="text/javascript">
    function formSubmit() {
         var formName2 = document.getElementById("proxy_form_main_").title;
         var formName1 = document.getElementById("BPSMacroFormId").title;
         document.getElementById("__LINK_TARGET__").value = document.getElementById("proxy_HD_COMMAND_").title;
         document.getElementById(formName2).submit();
         return false;
    </script>
    <f:view>
         <hx:scriptCollector id="bpsMacroScriptCollector">
              <f:loadBundle var="bps" basename="bordereauprocessingsystem" />
              <table bgcolor="#FFF9C3">
                   <tr>
                        <td><h:form id="BPSMacroFormMain" styleClass="form">
                             <table class="tablemiddle" cellspacing="0" cellpadding="0">
                                  <tr>
                                       <td><h:messages layout="table" styleClass="errormessage"
                                                 id="ValidationErrorMsg" /> </td>
                                  </tr>
                             </table>
                             <j4j:idProxy id="proxy_form_main_0_" />
                        </h:form></td>
                   </tr>
                   <tr>
                        <td>
                        <form id="BPSMacroFormId" enctype="multipart/form-data">
                        <table bgcolor="#FFF9C3">
                             <tr>
                                  <td height="36" width="324">Worksheet <input type="file"
                                       name="upfile" /></td>
                             </tr>
                                  <tr>
                                       <td align="center" width="324"><input TYPE="submit"
                                       onclick="return formSubmit();" value="Upload">
                                  </td>
                             </tr>
                        </table>
                        </form>
                        </td>
                   </tr>
                   <tr>
                        <td>
                        <h:form id="BPSMacroFormMain2" styleClass="form">
                             <table cellspacing="2" cellpadding="2" class="tablemiddle">
                                  <tbody>
                                       <tr>
                                            <td colspan="2" align="center"><h:commandLink
                                                 styleClass="commandLink" id="lnkuserdelete"
                                                 action="#{pc_BPSMacro.doIdUpload1Action}">
                                                 <hx:graphicImageEx
                                                      styleClass="graphicImageEx" id="imgBtnCreateUser"
                                                      value="/theme/images/btnUpload.gif" style="border:0;cursor:pointer"></hx:graphicImageEx>
                                                 <j4j:idProxy id="proxy_HD_COMMAND_" />
                                            </h:commandLink></td>
                                            <h:inputHidden id="dtSize"
                                                 value="#{pc_BPSMacro.fileDetailsList.clicked}">
                                                 <j4j:idProxy id="proxy_clicked_" />
                                            </h:inputHidden>
                                       </tr>
                                  </tbody>
                             </table>
                             <j4j:idProxy id="proxy_form_main_" />
                        </h:form>
                   </td>
                   </tr>
              </table>
         </hx:scriptCollector>
    </f:view>
    ================== END: FACES JSP FILE: BPSMacro.jsp ========================
    2:
    =================== Action event in the Page Code: BPSMacro.java ============
    public String doIdUpload1Action() {
              System.out.println("PageCode");
              FacesContext context = FacesContext.getCurrentInstance();
              BPSMacroDetailsDataBean fileDetails = (BPSMacroDetailsDataBean)context.getApplication().createValueBinding("#{fileDetails}").getValue(context);
              BPSMacroListDataBean fileDetailsList = (BPSMacroListDataBean)context.getApplication().createValueBinding("#{fileDetailsList}").getValue(context);
              PortletSession sess = (PortletSession)context.getExternalContext().getSession(false);
              sess.setAttribute("BPS_MACRO_CONTEXT", context, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_DETAILS", fileDetails, PortletSession.APPLICATION_SCOPE);
              sess.setAttribute("BPS_MACRO_FILE_LIST", fileDetailsList, PortletSession.APPLICATION_SCOPE);
              HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
              boolean isMultipart = ServletFileUpload.isMultipartContent(request);
              request.getContentType();
              return "gotoBPSMacro";
    ============== END Of Page Code Action event ==============================
    3:
    ============== doView() Portlet method ================================
    public void doView(RenderRequest arg0, RenderResponse arg1)
         throws PortletException, IOException {
              String METHOD_NAME = "doView(RenderRequest arg0, RenderResponse arg1)";
              Logger.debug(this.getClass(), METHOD_NAME, "Entering BPSMacroPortlet");
              FacesContext context = FacesContext.getCurrentInstance();      
              PortletSession sess1 = arg0.getPortletSession(true);
              BPSMacroDetailsDataBean fileDetails = new BPSMacroDetailsDataBean();
              BPSMacroListDataBean fileDetailsList = new BPSMacroListDataBean();
              context = (FacesContext)sess1.getAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              if(context != null){
                   fileDetails = (BPSMacroDetailsDataBean)sess1.getAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
                   fileDetailsList = (BPSMacroListDataBean)sess1.getAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_CONTEXT", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_DETAILS", PortletSession.APPLICATION_SCOPE);
              sess1.removeAttribute("BPS_MACRO_FILE_LIST", PortletSession.APPLICATION_SCOPE);
              HttpServletRequest servletRequest = (HttpServletRequest)arg0;
              PortletRequest pReq = (PortletRequest)arg0;
              HttpServletResponse servletResponse= (HttpServletResponse)arg1;
              System.out.println("\n\n Content Type" + servletRequest.getContentType());
              try{
                   if(context != null){
              boolean isFileMultipart = ServletFileUpload.isMultipartContent(servletRequest);
              System.out.println("\nFILE TO BE UPLOADED IS MULTIPART ? " + isFileMultipart);
              if(isFileMultipart){
                   FileItemFactory factory = new DiskFileItemFactory();
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   List items = upload.parseRequest(servletRequest);
                   Iterator iterator = items.iterator();
                   while (iterator.hasNext()) {
                        FileItem item = (FileItem) iterator.next();
                        InputStream iStream = item.getInputStream();
                        ByteArrayOutputStream ByteArrayOS = new ByteArrayOutputStream();
                        int sizeofFile =(int) item.getSize();
                        byte buffer[] = new byte[sizeofFile];
                        int bytesRead = 0;
                        while( (bytesRead = iStream.read(buffer, 0, sizeofFile)) != -1 )
                             ByteArrayOS.write( buffer, 0, bytesRead );
                        String data = new String( ByteArrayOS.toByteArray() );
                        int k = 0;
                        //Check if the file is Refund or Premium
                        int dynamicArraySize = 0;// = st2.countTokens() * 9;
                        dynamicArraySize = st2.countTokens() * 9;
                        if (!item.isFormField() ){
                             File cfile=new File(item.getName());
                             String fileName = "";
                             String separator = "\\";
                             int pos = item.getName().lastIndexOf(separator);
                             int pos2 = item.getName().lastIndexOf(".");
                             if(pos2>-1){
                                  fileName =item.getName().substring(pos+1, pos2);
                             }else{
                                  fileName =item.getName().substring(pos+1);
                             File fileToBeUploaded=new File("C:\\Sal\\BPS MACRO\\FileTransfer\\Desti", fileName);
                             item.write(fileToBeUploaded);
                             validate.displaySuccessMessage(context);
              }catch(Exception e){System.out.println(e);
              Logger.debug(this.getClass(), METHOD_NAME, "Leaving BPSMacroPortlet");
              super.doView(arg0, arg1);
    ==== END: doView method in the portle class. ================================
    Thanks.

    one more question. Is there a way where I can submit two forms ?
    Thats is submit 2nd form only when the first form is submitted.
    I tried this it works.
    function formSubmit(){
    document.form1.submit();
    alert();
    document.form2.submit();
    But If I dont put an alert(basically it disables the parent page) in between, only the second form is submitted.
    If I put a delay of say 3 seconds in between then it will throw a SOCKET CLOSED error in the code triggered due to first form submit.
    Thus disabling the paresnt page for a few seconds is reolving my problem.
    Any ideas ?
    Well Basically when the Alert pop's up the parent page "STALLS" and thus the form2 does not submit till I click on OK, Is there a way I can stall the browser/Parent JSP page using JAVA SCRIPT ??
    Edited by: hector on Oct 9, 2007 11:09 AM
    Edited by: hector on Oct 9, 2007 2:12 PM

  • Need help on File uploading in JSF

    Hi All,
    i have to upload some document into IBM DB2 Content Management using JSF Portlet.
    Is it possible to upload a document( in my case it is an image) using JSF Portlet into IBM DB2 Content Management? and also i need to keep the reference of the uploaded document in DB2 database.
    i need some sample code to do this.
    the tools i am using are
    RAD 6.0 as IDE
    IBM DB2 Content Managener 8.3
    IBM DB2 8.2
    its an urgent requirement please help me out in this regard

    If it's possible in Portlets i don't know, but in JSF is possible with the Tomahawk component to upload files.
    See
    www.myfaces.org
    Try it.

  • [JSF 2] File upload. Is this feature handled already?

    Hello,
    I need to allow a user to upload many files through the same form.
    This is what I would have done with Struts with this HTML code:
    <input type="file" name="file1" size="62" value="" />
    <input type="file" name="file2" size="62" value="" />
    <input type="file" name="file3" size="62" value="" />and the use of the org.apache.struts.upload.+FormFile+.
    However, I see no direct access to this feature through the JSF 2.0.
    no special <h:> tag.
    Reading old JSF code on the web, Tomahawk or Icefaces were used for this task.
    But today, Tomahawk doesn't support JSF 2, and Icefaces has an 2.0 Alpha 2 version that offers many features except File Upload that is still not working (for their update of the month of January: no updates since?).
    More than that, I was trapped few days ago by a strange behavior of JSF 2.0.
    Setting a "+multipart/form-data+" enctype to my form made JSF 2.0 loop on form validation, without ever submitting it.
    I am sure I didn't dreamed when it happened to me. And removing that enctype made the <h:form> returning to its default "+application/x-www-form-urlencoded+" enctype generation, and everything went fine then.
    But I know that attempting to upload files form a web page involve setting a "+multipart/form-data+" enctype on it... I feel doomed.
    All these questions make me return to you all, again. I wonder if you have succeed in using file upload with JSF 2.0 already.
    What mean do you use for that? Any component already exist that is compliant with JSF 2.0?
    Thanks for your help,
    Grunt.

    Are you aware that multi-part forms are not supported by Servlet implementations out of the box? You need to add a filter or manually invoked multi-part processing to support file uploads in any Servlet based solution.You're right. Until JSF 2 takes benefits from Servlet 3.0 who offers a getPart() function, a filter looks mandatory.
    Therefore, I tried the most advanced "faces" available for file upload: Primefaces 2.0.2, who provides a filter. However, it's not enough. The whole Primefaces solution for file uploading works chaotically. For me, it handles the multipart request well, but isn't able to join the listener the uploadFile tag defines, at submission time. I won't enter into details because this is not the good forum to discuss of that specific trouble of Primefaces. I did post my problem on Primefaces forum, and learned that this feature isn't working well yet.
    Icefaces doesn't offer the file uploading currently. Even its compatilibilty mode to version 1.8 is told (by the release note) not being able to handle file uploading yet.
    Richfaces just began its version 4.0.0 and is far from offering file uploading.
    If creating a working file upload was something possible yet, I can say for sure that any of these "faces" would had offered a working feature the sooner they could. But rather than that, I am reading ideas about some Mojarra 2 low level bugs that would disallow this feature to be implemented at the moment.
    It can't be only a story of a filter to write. That filter would have been written already hundred of times, else. A complete working solution would be shown everywhere.
    Currently, to summarize all, whatever a theorical reason is given, or a practical one (RFE missing, no time to write it, not a critical feature, or even unwished feature, depending of everyone thoughts in the previous replies to this post), file uploading is not available for JSF 2.0 by any existing way. No tier API or Faces is able to provide it, as it could be easily proven by the fact... that no samples are currently existing, working.
    Myself, but I might be alone believing it, I consider this missing feature like a JSF 2 flaw.
    I guess its a mojarra internal bug that disallows developers to provide a solution yet. This is not abnormal: JSF 2.0 has six months only, and can't work perfectly yet.
    But the more the correction of that feature will be delayed, and the more the developers will be in trouble, as nothing else is able to work in compatibility with JSF 2.0 (no existing working sample, I need to repeat it). And worst than that, this kind of flaw is one of those that in enterprise, at decision time, can makes JSF 2 discarded for another framework, less smart, but doing everything expected. It would be a shame, then.
    So, I think this problem should not be taken disdainfully. It's not a matter of "+You should only put a filter here+", "+It's not our work+", "+Please write our specs+", "+Wait, only wait, it will come for sure one day...+". Its more significant than that. It requires your study. The one of competent people like you are, and having goodwill. Because I understand that this is a problem that has been thrown away since a long time! But it is returning back to us like a boomerang at great speed.
    Among the features that JSF 2 offers and the ones that are currently under development, they are many, many of them, that will look secondary if at the end of all, file uploading isn't available.
    Regards,
    Grunt.

  • File Upload Problem in JSF

    Hi all,
    I have a problem in file upload. I have a file upload third party component which uploads the file with the filter action depending on the url. My requirement is to trace the uploaded filename for addressing it with the database record. So I need the filename in my backing bean to store it in the database. Ho can i get the filename from view page to backing bean. Any Ideas and help please.
    Many thanx,
    vijaycanaan

    Mr BalusC,
    Yes Iam talking about a custom made upload component. The fileupload tutorials u send are good but my requirement is not meeting them. Among my requirements one is mutilple file uploads in the single view page. This is possible at present with my custom upload componet. Only if the problem gets solved. Any way once again please think on my problem and give your solution on it.
    Here is my problem:
    The problem is I have to access the components from view page which this kind of requirement possible in jsp by request parsing which results the key value pairs of the form components. This same thing/way I should get in backing bean from JSF view page.
    The solution I want may like as follows.
    Note this code is incorrect and wrong but for to understand my requirement.
    someobject.getComponentIdValue("clientID"); which returns a string value as d:\images\Tutle.jpg
    The clientID is upload file component' Id . In the request it may be the key associated with value as file complete path. By this kind of way my upload filter is able to get the orignal file. Ok i need this in my  backing bean to get the orignal filename to insert into the database. Please for this give the solution or reply.many thanx,
    vijaycanaan.

  • Upload file component in JSF 1.2

    Hi,
    I am developing an application with JSF 1.2 . I am using a custom component made with Apache Commons FileUpload 1.2.1 API which purpose is to upload files. This component work only if the form data is encoded with the “multipart/form-data” encoding instead of the usual “application x-www-form-urlencoded” encoding. From what I know JSF 1.2 doesn't handle this type of encoding. To overcome this issue, I install a servlet filter that intercepts a file upload and turns uploaded files into request attributes. The problem is that when the form data is encoded with the “multipart/form-data” encoding no characters are encoded. I have other JSF components in this form and in them I put different international characters which are lost when the form is submit because they are not encoded.
    Can somebody help me with this issue ?

    I have a filter
    import java.io.File;
    import java.io.IOException;
    import java.util.Collections;
    import java.util.Enumeration;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletRequestWrapper;
    import org.apache.commons.fileupload.FileItem;
    import org.apache.commons.fileupload.FileUploadException;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    public class UploadFilter implements Filter {
    private int sizeThreshold = -1;
    private String repositoryPath;
    public void init(FilterConfig config) throws ServletException {
    repositoryPath = config.getInitParameter(
    "com.corejsf.UploadFilter.repositoryPath");
    try {
    String paramValue = config.getInitParameter(
    "com.corejsf.UploadFilter.sizeThreshold");
    if (paramValue != null)
    sizeThreshold = Integer.parseInt(paramValue);
    catch (NumberFormatException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    public void destroy() {
    public void doFilter(ServletRequest request,
    ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
    if (!(request instanceof HttpServletRequest)) {
    chain.doFilter(request, response);
    return;
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    boolean isMultipartContent
    = ServletFileUpload.isMultipartContent(httpRequest);
    if (!isMultipartContent) {
    chain.doFilter(request, response);
    return;
    DiskFileItemFactory factory = new DiskFileItemFactory();
    if (sizeThreshold >= 0)
    factory.setSizeThreshold(sizeThreshold);
    if (repositoryPath != null)
    factory.setRepository(new File(repositoryPath));
    ServletFileUpload upload = new ServletFileUpload(factory);
    try {
    List<FileItem> items = (List<FileItem>) upload.parseRequest(httpRequest);
    final Map<String, String[]> map = new HashMap<String, String[]>();
    for (FileItem item : items) {
    String str = item.getString();
    if (item.isFormField())
    map.put(item.getFieldName(), new String[] { str });
    else
    httpRequest.setAttribute(item.getFieldName(), item);
    chain.doFilter(new
    HttpServletRequestWrapper(httpRequest) {
    public Map<String, String[]> getParameterMap() {
    return map;
    // busywork follows ... should have been part of the wrapper
    public String[] getParameterValues(String name) {
    Map<String, String[]> map = getParameterMap();
    return (String[]) map.get(name);
    public String getParameter(String name) {
    String[] params = getParameterValues(name);
    if (params == null) return null;
    return params[0];
    public Enumeration<String> getParameterNames() {
    Map<String, String[]> map = getParameterMap();
    return Collections.enumeration(map.keySet());
    }, response);
    } catch (FileUploadException ex) {
    ServletException servletEx = new ServletException();
    servletEx.initCause(ex);
    throw servletEx;
    a render
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.UnsupportedEncodingException;
    import javax.el.ValueExpression;
    import javax.faces.FacesException;
    import javax.faces.component.EditableValueHolder;
    import javax.faces.component.UIComponent;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    import javax.faces.render.Renderer;
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.commons.fileupload.FileItem;
    public class UploadRenderer extends Renderer {
    public void encodeBegin(FacesContext context, UIComponent component)
    throws IOException {
    if (!component.isRendered()) return;
    ResponseWriter writer = context.getResponseWriter();
    String clientId = component.getClientId(context);
    writer.startElement("input", component);
    writer.writeAttribute("type", "file", "type");
    writer.writeAttribute("name", clientId, "clientId");
    writer.endElement("input");
    writer.flush();
    public void decode(FacesContext context, UIComponent component) {
    ExternalContext external = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) external.getRequest();
    String clientId = component.getClientId(context);
    FileItem item = (FileItem) request.getAttribute(clientId);
    Object newValue;
    ValueExpression valueExpr = component.getValueExpression("value");
    if (valueExpr != null) {
    Class valueType = valueExpr.getType(context.getELContext());
    if (valueType == byte[].class) {
    newValue = item.get();
    else if (valueType == InputStream.class) {
    try {
    newValue = item.getInputStream();
    } catch (IOException ex) {
    throw new FacesException(ex);
    else {
    String encoding = request.getCharacterEncoding();
    if (encoding != null)
    try {
    newValue = item.getString(encoding);
    } catch (UnsupportedEncodingException ex) {
    newValue = item.getString();
    else
    newValue = item.getString();
    ((EditableValueHolder) component).setSubmittedValue(newValue);
    ((EditableValueHolder) component).setValid(true);
    Object target = component.getAttributes().get("target");
    if (target != null) {
    File file;
    if (target instanceof File)
    file = (File) target;
    else {
    ServletContext servletContext
    = (ServletContext) external.getContext();
    String realPath = servletContext.getRealPath(target.toString());
    file = new File(realPath);
    try { // ugh--write is declared with "throws Exception"
    item.write(file);
    } catch (Exception ex) {
    throw new FacesException(ex);
    and a simple tag handler it is nothing special.
    This code is taken from an example in the book Core JavaServer Faces Second Edition 2007

  • File upload program by jsf

    I am doing one file upload program using
    <af:inputFile label="File to Upload" columns="90"
    value="#{FileProcessor.uploadedFile}"/>
    component..
    in Jdeveloper 11g i am getting the correct result,
    but when i'm tryin to run it in Jdeveloper jdevstudio10131 it is giving this error.
    java.io.EOFException: Per-request disk space limits exceeded. at oracle.adfinternal.view.faces.webapp.UploadedFileImpl.loadFile(UploadedFileImpl.java:187) at
    i want this file upload application to run in ecplise..but there it is not working..do i need so some to import some jar files??
    tomat 5.0 i'm using there..
    Or is there any otherway to upload file using jsf component which should work in eclipse-tomcat enviornment also..
    please help
    thanks

    Mr BalusC,
    Yes Iam talking about a custom made upload component. The fileupload tutorials u send are good but my requirement is not meeting them. Among my requirements one is mutilple file uploads in the single view page. This is possible at present with my custom upload componet. Only if the problem gets solved. Any way once again please think on my problem and give your solution on it.
    Here is my problem:
    The problem is I have to access the components from view page which this kind of requirement possible in jsp by request parsing which results the key value pairs of the form components. This same thing/way I should get in backing bean from JSF view page.
    The solution I want may like as follows.
    Note this code is incorrect and wrong but for to understand my requirement.
    someobject.getComponentIdValue("clientID"); which returns a string value as d:\images\Tutle.jpg
    The clientID is upload file component' Id . In the request it may be the key associated with value as file complete path. By this kind of way my upload filter is able to get the orignal file. Ok i need this in my  backing bean to get the orignal filename to insert into the database. Please for this give the solution or reply.many thanx,
    vijaycanaan.

  • JSF RI 1.0 File Uploads mit Multipart Filter

    Hi there,
    I already posted my problem - I need support for a basic file upload. My requirement is, that I want to access teh file data in a Managed Bean method and then decice what to to with it.
    I decided to use Jason Hunters Multipart Filter, that comes with the oreilly servlet jar file. My problem with the following code is, that the upload() method is never called. I think the filter is not invoked, but I don't know why. Could anyone please see, if I am on the right track?
    First, here is my web.xml with the filter:
         <!-- OReilly MultiPart Filter - by Jason Hunter -->
         <!-- JSF RI 1.0 cannot handle MutliPart Requests -->
    <filter>
    <filter-name>multipartFilter</filter-name>
    <filter-class>com.oreilly.servlet.MultipartFilter</filter-class>
    <!-- we do not specify a special directory, the servlet containers tmp directory is used
    <init-param>
    <param-name>uploadDir</param-name>
    <param-value>/tmp</param-value>
    </init-param>
    -->
    </filter>
    <filter-mapping>
    <filter-name>multipartFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    --> this code comes at the end of my web.xml, so after the jsf cotnroller servlet is configured, etc.
    in my jsp page, I got this form:
    <h:form enctype="multipart/form-data">
    <table width="100%" border="1" cellspacing="2" cellpadding="2">
    <tr>
    <td width="25%" align="right">Bild</td>
    <td width="75%"><input type="file" name="file"></td>
    </tr>
    <tr>
    <td> </td>
    <td><h:commandButton id="upload" action="#{uploadBean.upload}" value="#{messages.uploadFile}"/>
         </td>
    </tr>
    </table>
    </h:form>
    --> the file upload is done with a normal html tag, because there is no jsf tag for it.
    then, here us may upload() method in the managed bean:
    (the upload method is never called... why???? )
         public String upload()
              log.debug("entering upload()...");
              // Files can be read if the request class is MultipartWrapper
              // Init params to MultipartWrapper control the upload handling
              HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
              if (request instanceof MultipartWrapper)
                   log.debug("The MultiPart Filter recognized the mulitpart request.");
                        // Cast the request to a MultipartWrapper
                        MultipartWrapper multi = (MultipartWrapper) request;
                        // Show which files we received
                        Enumeration files = multi.getFileNames();
                        while (files.hasMoreElements())
                             String name = (String) files.nextElement();
                             String filename = multi.getFilesystemName(name);
                             String type = multi.getContentType(name);
                             File f = multi.getFile(name);
                             log.debug("name: " + name);
                             log.debug("filename: " + filename);
                             log.debug("type: " + type);
                             if (f != null)
                                  log.debug("length: " + f.length());
              return "upload";
    THANX! it would be great to get this sample running!

    Hello!
    I have a photo which I store in MSSQL db as a BLOB so it looks like:
    | |
    | Photo |
    | |
    -----------------------+
    | c:\my.jpg | choose |
    -----------------------+
    where
    <f:verbatim>
    <input name="photo" id="photo" type="file">
    </f:verbatim>
    is rendered into standard choose file dialog (unfortunately I can't change it).
    So when user click "choose" it's able to select local file (a picture).
    Then in textbox (input) appear the path (of course it can write it directly).
    A click to the picture
    a) launch javascript:
    onclick="document.getElementById('photo').name='#{DatosPersonalesForm.foto}';"
    that change image value (file name) so I could know which file to look for later:
    <h:graphicImage value="#{DatosPersonalesForm.foto}" ...
    b) after this id calls the actionListener:
    <h:commandLink actionListener="#{DatosPersonalesForm.uploadPhoto}" ...
    In DatosPersonalesForm I have foto property (with get/set) which store foto
    public String getFoto()
    public void setFoto()
    The problem is how to return foto: I put an image in a session and get it from another servlet (registred in web.xml) which intercepts /images/* and return ones from the session.
    I tried use Base64 encoding to embedd images directly, but it works only in Mozilla (even it's html 4.01).
    here is my full DatosPersonalesForm.class (with some additional crap):
    public class DatosPersonalesForm implements Observer, Serializable
    private int idCentro = 1;
    private CurrentClient client;
    private String foto;
    //private String data;
    private Abonado abonado;
    private Persona persona;
    private DireccionTableModel direcciones;
    public DatosPersonalesForm()
    abonado = new Abonado();
    persona = new Persona();
    direcciones = new DireccionTableModel();
    public void setClient(CurrentClient client)
    this.client = client;
    client.addObserver(this);
    public void setIdCentro(int idCentro)
    this.idCentro = idCentro;
    direcciones.setIdCentro(idCentro);
    public void setIdAbonado(int idAbonado)
    if (idAbonado > 0)
    try
    abonado = AbonadoDAO.load(idAbonado, idCentro);
    persona = PersonaDAO.load(idAbonado, idCentro);
    catch (Exception ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    else
    abonado = new Abonado();
    persona = new Persona();
    direcciones.setIdPersona(idAbonado);
    public Abonado getAbonado() { return abonado; }
    public void setAbonado(Abonado abonado) { this.abonado = abonado; }
    public Persona getPersona() { return persona;}
    public void setPersona(Persona persona) { this.persona = persona; }
    public DireccionTableModel getDirecciones() { return direcciones; }
    public void setDirecciones(DireccionTableModel direcciones) { this.direcciones = direcciones; }
    //public String getData() { return data; }
    public String getFoto()
    if (persona != null)
    try
    Imagenes imagenes = ImagenesDAO.load(persona.getIdImagen(), idCentro);
    if (imagenes != null)
    foto = "/images/" + putImage(imagenes.getImagen());
    //data = Base64Encoder.encode(imagenes.getImagen());
    catch (Exception ex)
    foto = "/img/photo_unavailable.jpg";
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    return foto;
    public void setFoto(String foto) { this.foto = foto; }
    public void uploadPhoto(ActionEvent e)
    // for which person to upload???
    if (persona != null)
    HttpServletRequest r = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
    if (r instanceof ServletRequestWrapper)
    ServletRequest req = ((ServletRequestWrapper)r).getRequest();
    if (req instanceof MultipartRequestWrapper)
    MultipartRequestWrapper request = (MultipartRequestWrapper)req;
    byte[] photo = (byte[])request.getFiles().get(foto);
    if (photo != null)
    try
    BufferedImage original = ImageIO.read(new ByteArrayInputStream(photo));
    if (original == null) // not an image?
    return;
    BufferedImage scaled = new BufferedImage(128, 160, BufferedImage.TYPE_INT_RGB);
    Graphics g = (Graphics2D)scaled.getGraphics();
    g.drawImage(original,0,0,128,160,null);
    g.dispose();
    ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
    ImageIO.write(scaled, "jpg", out);
    photo = out.toByteArray();
    catch (IOException ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    return;
    Imagenes imagenes = new Imagenes();
    imagenes.setIdCentro(idCentro);
    imagenes.setIdImagenes(persona.getIdImagen());
    imagenes.setImagen(photo);
    try
    ImagenesDAO.save(imagenes);
    catch (Exception ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    return;
    putImage(imagenes.getImagen());
    public String clear()
    if (client != null)
    client.setIdAbonado(0);
    // must be mapped in faces-config.xml
    return "clear";
    public void save(ActionEvent e)
    try
    if (persona.getIdPersona() == 0)
    abonado.setIdCentro(idCentro);
    persona.setIdCentro(idCentro);
    Connection con = DatasourceFactory.getConnection();
    try
    con.setAutoCommit(false);
    PersonaDAO.create(con, persona);
    abonado.setIdAbonado(persona.getIdPersona()); // idPersona == idAbonado is autoGenerated by database
    AbonadoDAO.create(con, abonado);
    con.commit();
    catch(SQLException ex)
    con.rollback();
    persona.setIdPersona(0);
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    finally { con.close(); }
    // notify all about client change
    if (client != null)
    client.setIdAbonado(persona.getIdPersona());
    else
    Connection con = DatasourceFactory.getConnection();
    try
    con.setAutoCommit(false);
    PersonaDAO.save(con, persona);
    AbonadoDAO.save(con, abonado);
    con.commit();
    catch(SQLException ex)
    con.rollback();
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    finally { con.close(); }
    catch (Exception ex)
    FacesContext.getCurrentInstance().getExternalContext().log(ex.toString());
    direcciones.save(e);
    private String putImage(byte[] image)
    String name;
    HttpSession ses = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
    if (ses != null)
    name = "photo_" + String.valueOf(idCentro) + "_" + String.valueOf(persona.getIdPersona()) + ".jpg";
    HashMap map = (HashMap)ses.getAttribute("ImageMap");
    if (map == null)
    map = new HashMap();
    ses.setAttribute("ImageMap", map);
    map.put(name, image);
    else
    name = null;
    return name;
    public void update(Observable o, Object arg)
    if (o instanceof CurrentClient)
    CurrentClient bean = (CurrentClient)o;
    setIdAbonado(bean.getIdAbonado());
    Cheers,
    D.
    P.S. I live in Spain so in Spanish it's foto :-) Sometimes I got crazy coz neither Spanish nor English are my native languages...
    More... in MultipartRequestWrapper you can easy remove
    public Object getAttribute(String name) method. It's my intention to map messages to request properties for easy access (like check if message exists to change style of some textfield in case of error). Do you know the better way???

  • JSF Calendar/ File Upload

    Can any one of you suggest me any tutorial about Calendar function? How to add the calendar component into Studio Creator? Highly appreciate your help.
    Also, I need help on File upload.

    Thanks for the information. But I have a question on Calendar component . I want the Calendar component to be open when user wants to enter a date. Otherwie it looks akward in a page to keep the component visible all the time. How do I do that? What I am thinking is, i want to make this small and upon clicking it will open the calendar and select date. Thanks for your help in advance.
    About Fileupload
    Do I have to copy any jar file from MyFaces. I am using SUN Studio Creator. Do I have to import anything?

  • 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

  • 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

  • File Upload Problem in Mozila

    Hi;
    My code is workin in IE but problem in Mozila Fireforx:
    <%@page import="org.apache.commons.fileupload.DiskFileUpload"%>
    <%@page import="org.apache.commons.fileupload.FileItem"%>
    <%@page import="java.util.List"%>
    <%@page import="java.util.Iterator"%>
    <%@page import="java.io.File"%>
    <%@page import="java.io.FileNotFoundException"%>
    <%@page import="java.io.BufferedReader"%>
    <%@page import="java.io.FileReader"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Upload Process</title>
    </head>
    <body>
    <%
    String record=null;
    try{
    System.out.println("Content_type:"+request.getContentType());
    DiskFileUpload fu = new DiskFileUpload();
    fu.setSizeMax(100000000);
    List fileItem = fu.parseRequest(request);
    Iterator iter = fileItem.iterator();
    FileItem fi = (FileItem)iter.next();
    if(!fi.isFormField()){
    File file = new File(fi.getName());
    out.println("NAME:"+fi.getName());
    File nFile = new File(application.getRealPath("/"),file.getName());
    // BufferedReader br =new BufferedReader(new FileReader(nFile));
    out.println("Name:"+nFile.getName());
    out.println("ABPath:"+nFile.getAbsolutePath());
    }else{
    System.out.println("Field ="+fi.getFieldName());
    } catch(Exception ex){
    ex.printStackTrace();
    %>
    </body>
    </html>
    Problem is for AbsolutePath it looking file under project directory.
    :D:\Dir name\build\web\.....
    PLEASE HELP
    Thanks in Advance
    Mamun

    Mr BalusC,
    Yes Iam talking about a custom made upload component. The fileupload tutorials u send are good but my requirement is not meeting them. Among my requirements one is mutilple file uploads in the single view page. This is possible at present with my custom upload componet. Only if the problem gets solved. Any way once again please think on my problem and give your solution on it.
    Here is my problem:
    The problem is I have to access the components from view page which this kind of requirement possible in jsp by request parsing which results the key value pairs of the form components. This same thing/way I should get in backing bean from JSF view page.
    The solution I want may like as follows.
    Note this code is incorrect and wrong but for to understand my requirement.
    someobject.getComponentIdValue("clientID"); which returns a string value as d:\images\Tutle.jpg
    The clientID is upload file component' Id . In the request it may be the key associated with value as file complete path. By this kind of way my upload filter is able to get the orignal file. Ok i need this in my  backing bean to get the orignal filename to insert into the database. Please for this give the solution or reply.many thanx,
    vijaycanaan.

  • 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

  • Problem in dynamically generating the file upload field

    Hello all
    I am using netbeans 5.5 and visualwebpack for my jsf project.
    i have a problem in dynamically generating the file upload field and using it.
    I have a panel say "panelA" which holds file upload fields.
    Depending upon the count value i generate the file upload field using following code snippet:
    Upload upload1 = new Upload();
    upload1.setId("upload1");
    getPanelA.getChildren().add(upload1);
    The page successfully shows up the file upload fields. While the user clicks the submit button, i have used following logic to perform upload:
    List components = getPanelA().getChildren();
    for(int i = 0; i<components.size(); i++){
    if(components.get(i) instanceof Upload){
    UploadedFile uploadedFile = ((Upload)components.get(i)).getUploadedFile();
    I am getting this UploadedFile object null.
    How can i solve this problem.

    Anyway,
    I solved the problem.
    Actually i was using label property of the upload field due to which i got null pointer exception.
    I removed the label property of the upload field and things worked as i wanted.

Maybe you are looking for

  • Voice memos from itunes to iphone

    Can you put voice memos from itunes into an iphone? - both new ones and old ones?

  • Upgrade from BW 2.0B to BI 7.0

    Hi, Our customer is planning to upgrade their BW system from 2.0B to BI 7.0. (HW type SPARC64, OS: Solaris 9 DB: Oracle 9i ) I am preparing Prerequisites list for the same. One of the prerequisite says, if we are planning to upgrade the BW 2.0B syste

  • Knowledge for Reporting

    hi As I am  new to the bi reporting world can u please tell me what is the  right way to move towards it  and more over please Explain me table content of all the module using in reporting concept Thanks Regards gurkiran

  • Forms 9i in 9iAS problem

    Hello, we have made a form in forms builder 9i, deployed it on our linux 9iAS. If we start the form the login-Dialog comes and after typing in the username, password and database the form appears. but if we execute an query in the form there will be

  • IPod sound problems.

    Hi there. I'm having trouble with my iPod, specifically I get distorted/no sound from the right channel on my headphones. This first happened last night when I was listening in bed. The sound from the right earphone started distorting before finally