Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're going to need a servlet for this. I've answered a Uploadify + Servlet question before which should give sufficient clues: <a href="https://stackoverflow.com/questions/2272160/uploadify-plugin-doesnt-call-java-servlet/2273711#2273711">Uploadify plugin doesn&#39;t call Java Servlet</a>. The concept is not that different for SWFUpload and YUI Uploader. Note that you can just put plain HTML in a JSF page without problems. </p> <p>Your main problem is enabling the JSF backing bean and the HTTP servlet to exchange data with each other. For this the HTTP session should be used. First let the JSF bean on initial request generate an unique key which is to be used as session attribute name:</p> <pre><code>key = UUID.randomUUID().toString(); </code></pre> <p>Then, in the upload URL which you tell Uploadify/SWFUpload/etc to use, you need to include the <code>jsessionid</code> URL fragment (so that the servlet will use the same HTTP session) and the <code>key</code>as URL query string parameter (so that the servlet will use this key to store relevant state about the file upload). Assuming that you need to specify it as a JS object key:</p> <pre><code>url: '${pageContext.request.contextPath}/uploadServlet;jsessionid=${pageContext.session.id}?key=&lt;h:outputText value="#{uploadBean.key}" /&gt;' </code></pre> <p>Now, the servlet will be invoked within the same HTTP session (i.e. <code>request.getSession()</code> will be exactly the same one as available in JSF by <code>ExternalContext#getSession()</code> and its attributes by <code>getSessionMap()</code>). So, in <code>doPost()</code> just do:</p> <pre><code>String key = request.getParameter("key"); request.getSession().setAttribute(key, someStateAboutTheUpload); </code></pre> <p>Finally, when JSF is about to process the form submit, just get the desired data by the key (which you store for the subsequent request by <code>&lt;input type="hidden"&gt;</code> or <code>&lt;t:saveState&gt;</code> in case of a request scoped bean):</p> <pre><code>SomeState someState = (SomeState) externalContext.getSessionMap().get(key); </code></pre> <p>The unique key is not necessary for the functioning, it can even be a static key, but a on per-view basis generated key ensures that the data doesn't clash when the enduser has the same view open in multiple browser tabs/windows in the same session.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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