 |
|
 |
Subject: Disable SaveOptions dialog from Java API while embedding attachments to rich text items |
 |
 |
 |
Product Area: Notes Client |
 |
Technical Area: User Interface |
 |
Platform: Windows |
 |
Release: 8.5.2 |
 |
Reproducible: Always |
 |
 |
 |
 |
I am looking to improve my approach to embedding attachments into rich text items using the Java API for Lotus Notes (code below). Right now, when I close the original UI document, I receive the “Save Options” dialog. Is there any way using the Java API to disable the showing of this dialog?
I know that I can do this with LotusScript by (1) setting the back end document field
“SaveOptions” to 0, (2) closing the UI document, (3)creating the UI document again by calling workspace.EditDocument(true, back-end document), and (4) setting "SaveOptions" to 1.
(NOTE - this assumes that the ui document is currently open and already in edit mode.
The code is wrapped in a NotesSessionJob class and we wrote methods to execute on different threads.)
NotesUIDocument uiDoc = getUIDoc();
Database notesDB = null;
//if front end document exists
if( uiDoc != null )
{
if( uiDoc.isNewDoc() || uiDoc.isEditMode() )
{
//save the ui doc
uiDoc.save();
}
NotesDatabaseData dbData = uiDoc.getDatabaseData();
if( dbData != null )
{
notesDB = getCurrentDatabase(session);
Document doc = notesDB.getDocumentByUNID( unid );
//if back end document exists
if( doc != null )
{
//get the Body
Item item = doc.getFirstItem( "Body" );
//'If it is rich text then we can grab the attachments
if( item != null && item.getType() == Item.RICHTEXT )
{
//get the RichTextItem so we can get the Embedded Objects
RichTextItem rtItem = (RichTextItem) item;
String fileName = "Test.txt";
//embed the file as an attachment
rtItem.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", "C:\\test.txt", fileName);
//get the notes ui field
NotesUIField notesField = uiDoc.getField("Body");
if( notesField != null )
{
//append the text
notesField.appendText(fileName);
}
//Update the RichText Item and show the text in the ui doc, but not
//does not show the attachment.
rtItem.update();
//get the workspace
NotesUIWorkspace workspace = new NotesUIWorkspace();
//attempt to compose the document
try
{
//compose the new document, which will display the attachment and text
//creates a new ui document
workspace.composeDocument(doc);
}
catch (NotesException e)
{
Log(e);
}
//Close the current uiDocument to get the attachments placed
//on the front end.
Utilities.ExecuteOnSWTThread(new Runnable()
{
@Override
public void run()
{
//Close the original UI document
//causes the Save Options dialog.
uiDoc.close();
}
});
}
}
}
}
 
Feedback number WEBB8MXNCR created by ~Mario Nonreskilen on 10/24/2011

Status: Open
Comments:

Disable SaveOptions dialog from Jav... (~Mario Nonreski... 24.Oct.11)
. . Java API while embedding attachment... (~Keiko Kiluvera... 9.Jan.12) |
|  |
|