Announcement Announcement Module
No announcement yet.
Support for Struts FormFile Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Support for Struts FormFile

    Hi all, I am trying to incorporate struts file upload in web flow. I'm running into a problem that struts FormFile is always null. However, my FlowAction extension class is able to access the FormFile.

    Here is my setup

    public class HtmlForm extends ActionForm {
    private FormFile uploadFile;
    public FormFile getUploadFile() {
    return uploadFile;
    public void setUploadFile(FormFile uploadFile) {
    this.uploadFile = uploadFile;

    public class HtmlAction extends FormAction{

    public HtmlAction() { ...}

    public Event process () {
    HtmlForm form = (HtmlForm)context.getFlowScope().get("htmlForm");
    // FormFile is always null
    FormFile ff = form.getUploadFile();

    public class CustomStrutsAction extends FlowAction {

    protected ActionForward doExecuteAction(org.apache.struts.action.ActionMap ping mapping,
    org.apache.struts.action.ActionForm form,
    javax.servlet.http.HttpServletRequest request,
    javax.servlet.http.HttpServletResponse response)
    throws java.lang.Exception {

    HtmlForm htform = (HtmlForm)form;
    // FormFile is not null
    FormFile ff = htform.getUploadFile();



    <action path="/home" forward="/WEB-INF/index.jsp"/>

    <action path="/wiz"
    name="htmlForm" scope="request"
    className="org.springframework.web.flow.struts.Flo wActionMapping">
    <set-property property="flowId" value="htmlWiz" />


    <html:form action="" method="post" enctype="multipart/form-data">
    <INPUT type="hidden" name="_flowExecutionId" value="<c:out value="${flowExecutionId}"/>">
    <INPUT type="hidden" name="_eventId" value="submit">
    <INPUT type="file" name="uploadFile">
    <INPUT type="submit" value="Next">

    I am really stuck here.. Hope someone can point me to the right direction..

  • #2
    My suggestion is to look in the code for FlowAction. Specifically the action form is a property of the source event, not one in request scope. So to access the form you need to do something like:

    ((StrutsEvent)context.getSourceEvent).getActionFor m();

    Ideally the action form should really be put in request scope for convenient access like this:

    context.getRequestScope().getAttribute("actionForm ")

    or possibly with the form object name of the FormAction, but that's a little trickier to do.