java - How to handle file uploads when other validation errors are thrown -


i have xpage fileupload control , fields. use serverside validation (some of fields need lookups etc. validate content). if user specifies file uploaded , 1 of other fields fails validate (showing message user) fileupload control loses client name (and file) - meaning user have select file again upload it.

any ideas how solve this? can uploaded temp. file "kept in memory" in e.g. view bean - , "injected" when validation doesn't fail other fields?

this question related same issue asked here: how can "keep" uploaded image on form validation error? - not give solution above (although discuss temp. file).

you should change ui , give user special button uploading files (maybe in modal dialog). here small example xpage:

<?xml version="1.0" encoding="utf-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core">     <xp:this.data>         <xp:dominodocument var="document1" formname="rtitem" action="editdocument" concurrencymode="force" />     </xp:this.data>      <xp:div id="refreshme">         <xp:fileupload  id="fileupload1" value="#{document1.body}" />          <xp:button value="upload file" id="buttonupload">             <xp:eventhandler event="onclick" submit="true" refreshmode="complete" disablevalidators="true" />         </xp:button>          <!-- download control show datasource -->          <xp:filedownload rows="30" id="filedownload1" displaylastmodified="false" value="#{document1.body}" />          <!-- required field , messages element -->         <xp:inputtext id="inputtext1" required="true" />         <xp:messages id="messages1" />          <!-- button refresh page -->         <xp:button value="refresh me" id="buttonrefreshme">             <xp:eventhandler event="onclick" submit="true" refreshmode="partial" refreshid="refreshme" />         </xp:button>      </xp:div>  </xp:view> 

you can combine ajax file uploader progress in background, give better ux users.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -