开发者

Field values gets reset to blank on seam file upload exception

开发者 https://www.devze.com 2023-04-09 15:43 出处:网络
I have jsf-seam application in which I am uploading a file using seam:fileUpload using the code below. Also, I have made a entry of multipart-filter to restrict file size to 1 MB.

I have jsf-seam application in which I am uploading a file using seam:fileUpload using the code below. Also, I have made a entry of multipart-filter to restrict file size to 1 MB.

<s:fileUpload id="offerImage" data="#{myBean.data}" contentType="#myBean.contentType}" fileName="#{myBean.fileName}" fileSize="#{myBean.size}" /> 

    <web:multipart-filter create-temp-files="true"
            max-request-size="1000000" 
            url-pattern="*.seam"/>

Everything is working fine, except when user try to upload a file greater than 1 MB, it throws a exception. I am handling 开发者_Go百科this exception as well in pages.xml.

<exception class="org.jboss.seam.web.FileUploadException">
  <redirect view-id="/create.xhtml">
   <message severity="ERROR">Error while uploading Offer Image, due to size limitation.</message>
  </redirect>

Issue here is: All other fields in create.xhtml(other than upload field) gets blank. User should not fill all the fields again, except the file upload.

Is there any way, where in I can redirect the user to same xhtml page with all the values filled by user persists when a seamFileUpload exception occurs.

Regards, Rajat


Are you running this page with components in conversation or page scope? If there is "just" an event scoped component your backingbeans will be initialized on each request and because of that you can have empty fields on the next rendering.

0

精彩评论

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

关注公众号