开发者

Restore view (displaying viewScoped Bean) after calling JSP for file upload

开发者 https://www.devze.com 2023-03-28 22:11 出处:网络
I\'m using JSF 2.1 RI. I\'ve a JSF Page with multipart upload form defined like: <form method=\"post\" enctype=\"multipart/form-data\" action=\"/addAttachment.jsp\">

I'm using JSF 2.1 RI.

I've a JSF Page with multipart upload form defined like:

<form method="post" enctype="multipart/form-data" action="/addAttachment.jsp">
    <input type="file" value="${myBean.filePath}" id="filePath" name="filePath"/>
    <input type="hidden" value="${myBean.id}" id="id" name="Id"/>
    <input type="text" value="" id="description" name="description"/>
    <input type="hidden" value="viewForm.html" id="redirectUrl" name="redirectUrl"/>
    <input type="submit" value="Upload File"/>
</form>

Here, myBean is ViewScoped as there may be multiple windows open doing file uploads in parallel on same client machine.

Now, the JSP has the code following Apache Commons to upload and store the file to the FTP server. After uploading the file, if "redirectUrl" is present in the parameters, the JSP redirects to that page using:

    response.sendRedirect(redirectUrl);

Now, as I've a dataTable in the JSF File (the one containing multipart upload form) showing the list of attached files, I want the navigation back on the same view (without recreating the bean as I've more information on other tabs which will get lost) and handle updation of datatable in pre开发者_如何学编程renderview event if possible.

Is there a way to achieve this?

Please let me know if I need to provide more information.

Thanks, Kapil.

0

精彩评论

暂无评论...
验证码 换一张
取 消