Tomahawk file upload and Spring Webflow

To add upload functionaility using Apache Tomahawk, first we have to enable a few things. The web.xml file will need a filter defined

  <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>

Next, in your JSP/Facelets or whatever view technology using, you must define the Apache Tomahawk namespace as shown below. (

declare your tomahawk namespace in jsp/xhtml

<ui:composition xmlns="<a href="http://www.w3.org/1999/xhtml"
</a>	xmlns:ui="<a href="http://java.sun.com/jsf/facelets"
</a>	xmlns:h="<a href="http://java.sun.com/jsf/html"
</a>	xmlns:f="<a href="http://java.sun.com/jsf/core"
</a>	xmlns:sf="<a href="http://www.springframework.org/tags/faces"
</a>	xmlns:t="<a href="http://myfaces.apache.org/tomahawk">
</a>	template="/WEB-INF/layouts/brown-standard.xhtml">

Then add the t:inputFileUpload to the JSF page. Note that 'myView' is a variable defined in the webflow.

<h:form id="MyForm" enctype="multipart/form-data">
  <h:panelGrid columns="1">
    <t:inputFileUpload id="myFileId" value="#{myView.uploadedFile}" 
    storage="file" />
  <div class="buttonGroup">
    <h:commandButton id="upload" value="Upload File" 
      action="submit" />
    <h:commandButton id="search" value="Back to Search"
      action="search" />

In your flow definition you can just show the action. tomahawk can do it 'behind the scenes' without declaring anything within webflow

<view-state id="selectUploadFile" model="uploadView">
  <transition on="submit" to="displayUploadFile" />
  <transition on="search" to="searchAndDisplayBudget"

In the object defined as 'myView' we have the following code. Also, this object should be defined in the flow itself.

public class MyView implements Serializable {
	private static final long serialVersionUID = 1L;
	private UploadedFile uploadedFile;
	public void setUploadedFile(UploadedFile up) {
		uploadedFile = up;
	public UploadedFile getUploadedFile() {
		return uploadedFile;

Then you should be able to utilize the UploadFile object in your code.

Post new comment

Subscribe to Syndicate