Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This can be done by removing all attachments first (use the removeAllAttachments function from NotesXSPDocument object) and then attach the uploaded file manually to the richtext item.</p> <p>This SSJS code has to be added to beforeRenderResponse-event of your XPage / Custom Control:</p> <pre><code>var con = facesContext.getExternalContext(); var request:com.sun.faces.context.MyHttpServletRequestWrapper = con.getRequest(); var map:java.util.Map = request.getParameterMap(); var fileDataName = getClientId('fileUpload1') ; var fileData:com.ibm.xsp.http.UploadedFile = map.get( fileDataName ); if( fileData == null ){ return; } var tempFile:java.io.File = fileData.getServerFile(); var correctedFile = new java.io.File( tempFile.getParentFile().getAbsolutePath() + java.io.File.separator + fileData.getClientFileName() ); var success = tempFile.renameTo(correctedFile); try{ document1.removeAllAttachments("Body"); }catch(e){} var rtFiles:NotesRichTextItem = null; if(!(document1.getDocument().hasItem("Body"))){ rtFiles = document1.getDocument().createRichTextItem("Body") }else{ rtFiles = document1.getDocument().getFirstItem("Body"); } rtFiles.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT, "", correctedFile.getAbsolutePath(), null); correctedFile.renameTo(tempFile); document1.save(); </code></pre> <p>The richtext item where the files are stored is "Body", the name of the datasource is "document1". The Fileupload control is "fileUpload1".</p> <p>There are two limitations:</p> <ol> <li>You cannot use this with a save button, you have to use a normal button / link which makes a full refresh (see what Serdar Basegmez wrote above)</li> <li>You have to refresh the page after a upload once again, otherwise you will not see the uploaded file in a file download conrol (maybe a partial refresh to this control may work).</li> </ol> <p><strong>EDIT:</strong></p> <p>Sorry, my fault: You <strong>can</strong> use this code above in a submit button that saves the document. Then you <strong>don't</strong> have to refresh the page manually!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload