Spring Web Flow is a neat framework for JSF navigation and action management. It may not be the most versatile or very advanced but it will handle almost all of the scenarios in web development. In the future they will finally get rid of Dojo dependency for ajax operations and allow any javascript library (jquery, prototype,etc) to be used instead.
http://www.springsource.org/go-webflow2
In any enterprise application users expect to generate Adobe PDF reports or Excel worksheets, but how do you map an action that retrieves a pdf back to the user using Spring Web Flow. Here is a perfect example from my own experience:
Flow definition
<transition on="getPdfreport" validate="false">
<evaluate
expression="someBean.getFile(flowRequestContext,requestParameters.selectedName)" />
</transition>
Class method
public void getFile(final RequestContext context, final String name
) throws Exception
{
//some standard code to set content
try{
final HttpServletResponse response = (HttpServletResponse) context
.getExternalContext().getNativeResponse();
response.setContentType("application/pdf");
final OutputStream out = response.getOutputStream();
out.write(fileContent);
out.flush();
out.close();
}catch(Exception ex){
log.error(ex);
}finally{
// its important to complete response otherwise the JSF rendering will
// fail
// java.lang.IllegalStateException: Response already committed
context.getExternalContext().recordResponseComplete();
}
}
The most important line here is recordResponseComplete(), it completes the response JSF cycle properly through SWF.
You must be passing the context in order to do this, see class: org.springframework.webflow.execution.RequestContext
Happy Programming