Java Reference
In-Depth Information
@FlowDefinition beans, should be packaged into their corresponding Java packages and accompanied by a beans.xml
file. The following outlines at the directory structure for a flow that is going to be packaged:
Ajax Queues
By default, JSF Ajax requests are held in an Ajax request queue on the client in order to ensure that requests are
sent to the server in the correct order. When a request is sent, it goes to the queue and waits until its turn to be sent
to the server. After the request is sent to the server, a callback method is invoked that will remove that request from
the queue.
A new delay attribute for the f:ajax tag allows a developer to specify a value in milliseconds that will be used
to meter the time between server requests. If multiple requests arrive to the queue within the specified delay period,
then only the most recent request is sent to the server. This prevents multiple unnecessary server requests from being
sent, which can help performance in your application and reduce network traffic. Using the new attribute would be
similar to the following example:
<h:commandButton value="Send Message" action="#{ajaxBean.sendMessage()}">
<f:ajax delay="500"/>
File Upload
JSF 2.2 includes a new file upload component that relies upon new Servlet 3.1 file upload support. The file upload
support can be Ajax enabled or non-Ajax enabled. A new JSF component named inputFile has been added to the list
of standard JSF components. This component can be used with or without the f:ajax tag, so files can be uploaded
with a page refresh (non-Ajax) or without (Ajax).
To utilize the inputFile component, it must be placed within a JSF form that has an enctype set to multipart/
form-data and no ID prepended. The h:form element contains the attributes enctype and prependId , which can be
used to set these values, respectively. The following line of code demonstrates how to set the attributes for a form
containing an inputFile component:
<h:form prependId="false" enctype="multipart/form-data">
The value of an inputFile component must be set to a managed bean variable that has a type of
javax.servlet.http.Part (named ajaxBean.upFile in the following example). A JSF command component or
the f:ajax tag should be set to an action method within the managed bean, which will save the file to disk.
The following JSF view demonstrates the use of the inputFile component in a non-Ajax solution:
<h:form prependId="false" enctype="multipart/form-data">
Choose a file to upload to the server:
<h:inputFile id="uploadFile" value="#{ajaxBean.upFile}">
<f:validator validatorId="FileValidator"/>
Search WWH ::

Custom Search