diff --git a/src/reference/actions.xml b/src/reference/actions.xml index aa29a2df..458b3908 100644 --- a/src/reference/actions.xml +++ b/src/reference/actions.xml @@ -415,10 +415,12 @@ public class PrintBoardingPassAction extends AbstractAction { HTML form is configured with enctype="multipart/form-data", you can easily handle the file upload in a transition action. - - Note that the File Upload example below below is not relevant when using Web Flow with JSF. - Check the documentation of your JSF component library to see what file upload components it provides. - + + + The file upload example below below is not relevant when using Web Flow with JSF. See + for details of how to upload files using JSF. + + Given a form such as: diff --git a/src/reference/spring-faces.xml b/src/reference/spring-faces.xml index a6bd26c5..77b944f8 100644 --- a/src/reference/spring-faces.xml +++ b/src/reference/spring-faces.xml @@ -699,6 +699,67 @@ mvn package + + Handling File Uploads with JSF + + Most JSF component providers include some form of 'file upload' component. Generally when working + with these components JSF must take complete control of parsing multi-part requests and Spring MVC's + MultipartResolver cannot be used. + + Spring Web Flow has been tested with file upload components from PrimeFaces and RichFaces. Check the + documentation of your JSF component library for other providers to see how to configure file upload. + + + File Uploads with PrimeFaces + PrimeFaces provides a <p:fileUpload> component for uploading files. In order + to use the component you need to configure the org.primefaces.webapp.filter.FileUploadFilter + servlet filter. The filter needs to be configured against Spring MVC's + DispatcherServlet in your web.xml: + + PrimeFaces FileUpload Filter + org.primefaces.webapp.filter.FileUploadFilter + + + PrimeFaces FileUpload Filter + Spring MVC Dispatcher Servlet +]]> + + For more details refer to the + PrimeFaces documentation. + + + + File Uploads with RichFaces + RichFaces provides a <rich:fileUpload> component for uploading files. No + special configuration is required to use the component, however, you will need to perform + some additional steps in your fileUploadListener. + Here is some typical XHTML markup. In this example the fileUploadBean refers + to Spring singleton bean. + +]]> + Within your fileUploadBean you need to tell Web Flow that the response has been + handled and that it should not attempt any redirects. The org.springframework.webflow.context.ExternalContext + interface provides a recordResponseComplete() for just such purposes. + In addition, it is imperative that some partial response data is returned to the client. If your + <rich:fileUpload> component does not specify a render attribute you + may need to call processPartial(PhaseId.RENDER_RESPONSE) on the JSF + PartialViewContext. + public class FileUploadBean { + + public void listener(FileUploadEvent event) throws Exception{ + FacesContext.getCurrentInstance().getPartialViewContext().processPartial(PhaseId.RENDER_RESPONSE); + ExternalContextHolder.getExternalContext().recordResponseComplete(); + UploadedFile file = event.getUploadedFile(); + // Do something with the file + } +} + For more details refer to the + RichFaces documentation. + + + Using the Spring Security Facelets Tag Library