Note that there are some explanatory texts on larger screens.

plurals
  1. POCommandButton action not invoked when using Tomahawk t:inputFileUpload
    primarykey
    data
    text
    <p>I'm using JSF 2.1 with JSP files. I tried to use JSF 2.1 with Facelet files, but didn't get Tomahawk (MyFaces extension) to work.</p> <p>I'm trying to upload a file using Tomahawk. My form looks like follows:</p> <pre><code>&lt;f:view&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt; &lt;title&gt;FILE UPLOAD&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;fieldset&gt; &lt;h:form enctype="multipart/form-data"&gt; &lt;t:inputFileUpload value="#{fileUploadBean.upFile}" size="25" required="true" /&gt;&lt;br/&gt; &lt;h:commandButton value="Validar" action="#{fileUploadBean.upload}" /&gt; &lt;/h:form&gt; &lt;/fieldset&gt; &lt;/body&gt; &lt;/html&gt; &lt;/f:view&gt; </code></pre> <p>and my bean is (as I'm using JSF 2.1, I don't need to use <code>faces-config.xml</code> and I use annotations):</p> <pre><code>import java.io.IOException; import java.io.InputStream; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import org.apache.myfaces.custom.fileupload.UploadedFile; /** * * @author federico.martinez */ @ManagedBean @RequestScoped public class FileUploadBean { private UploadedFile upFile; public UploadedFile getUpFile(){ return upFile; } public void setUpFile(UploadedFile upFile){ this.upFile = upFile; } public String upload(){ InputStream is = null; try { is = upFile.getInputStream(); long size = upFile.getSize(); byte[] buffer = new byte[(int)size]; is.read(buffer,0,(int)size); is.close(); System.out.println("File Upload Successful."); return "processing-file"; } catch (IOException ex) { Logger.getLogger(FileUploadBean.class.getName()).log(Level.SEVERE, null, ex); return "error-lf"; } finally { try { is.close(); } catch (IOException ex) { Logger.getLogger(FileUploadBean.class.getName()).log(Level.SEVERE, null, ex); } } } } </code></pre> <p>Well that's it, but finally the problem is when I click on h:commandButton, it doesn't do anything. It seems like the method "upload" from my bean isn't working or something. what am I missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload