Reputation: 809
I would like to make a confirmation before continue. I mean rest of codes should not run a until a user make a decision (Yes/No). If a user push the button "YES" It should create a new document. If the user chose "NO" nothing should happen.
in this code a confirmation dialog appears that asks "Are you sure to create new Document"
My problem is
a new document is already created If the user chose "Yes or no". this codes below does not care answer in the Dialog? Whole code runs then that dialog appears. I think i miss something :(
var dateOther = docOther.getFirstItem("TarihBitis").getDateTimeValue();
if (dateOther==null)
{
var dlgA = getComponent("dialogTarifeConfirm");
dlgA.show();
//Creating New Doc...
var docNew = database.createDocument();
docNew.appendItemValue("Subject", requestScope.subject);
docNew.appendItemValue("fieldName1", viewScope.fieldName1);
docNew.appendItemValue("fieldName2", viewScope.fieldName2);
docNew.save();
}
Any suggestion is appreciated. Regards Cumhur Ata
UPDATE 1 : Please find Where i am mixed after the dialog codes does not care the answer both document are created then the dialog will appear on the screen. I think I miss something that I don't know.
try
{
//Sync backend document with changes made in the frontend document
var doc:NotesDocument = document1.getDocument(true);
var today:NotesDateTime = session.createDateTime(@Now());
var bugun:java.util.Date = new java.util.Date();
var dateFormat = new java.text.SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
cn = sessionScope.commonUserName;
//getCurrnetUserName as String
var user:String=session.getEffectiveUserName();
var tKey = doc.getItemValueString("ParentUNID");
var ParaBirimi = document1.getItemValueString("ParaBirimi");
var tarifeView:NotesView = database.getView("(viewStandartTarifelerKontrol)");
var vec:NotesViewEntryCollection = tarifeView.getAllEntriesByKey(ParaBirimi);
var docBuUNID = document1.getDocument().getUniversalID();
if(document1.isNewNote())
{
if (vec.getCount() > 0)
{
var entry1:NotesViewEntry = vec.getFirstEntry();
while (entry1!= null)
{
var tarifeDoc:NotesDocument = entry1.getDocument();
var tarifeUNID = tarifeDoc.getUniversalID();
var ParentUNID = tarifeDoc.getItemValueString("ParentUNID");
if (docBuUNID!=tarifeUNID)
{
var tarifeDocBasDate:NotesDateTime = tarifeDoc.getItemValueDateTimeArray("startDate").elementAt(0);
var docBuBasDate:NotesDateTime = doc.getItemValueDateTimeArray("startDate").elementAt(0);
var days:int = tarifeDocBasDate.timeDifferenceDouble(docBuBasDate) / 86400;
diff = docBuBasDate.timeDifference(tarifeDocBasDate)/86400;
var a = tarifeDoc.getFirstItem("endDate").getDateTimeValue();
if (a==null)
{
if(diff>0)
{
var a = getComponent("dialogConfirm1");
a.show();
//If the user say YES FORMA document will be created.
var docNew = database.createDocument();
docNew.appendItemValue("Subject", viewScope.subject);
docNew.appendItemValue("Form","FormA");
//If the user say NO FORMB document will be created.
var docNew = database.createDocument();
docNew.appendItemValue("Subject", viewScope.subject);
docNew.appendItemValue("Form","FormB");
docNew.save();
}
}
}
var tmpentry = vec.getNextEntry();
entry1.recycle();
entry1 = tmpentry;
}
}
}
}
catch(e)
{
print(e);
}
Upvotes: 0
Views: 449
Reputation: 705
Can you not use "this.message"?
A simple example of using it to delete documents could be:
<xp:button value="Delete" id="button3"
styleClass="btn btn-danger btn-block btn-xs">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:confirm>
<xp:this.message><![CDATA[#{javascript:"Are you sure you want to delete this document?"}]]></xp:this.message>
</xp:confirm>
<xp:actionGroup>
<xp:this.condition><![CDATA[#{javascript:var id = rowData.getUniversalID();
var doc:NotesDocument = database.getDocumentByUNID(id);
doc.remove(true);}]]></xp:this.condition>
</xp:actionGroup>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
Upvotes: 1
Reputation: 1417
<xp:button id="btnDialogTarifeConfirm" value="Create New Document">
<xp:eventHandler event="onclick" submit="true" execMode="partial" execId="btnDialogTarifeConfirm">
<xp:this.action><![CDATA[#{javascript:var dialogTarifeConfirm:com.ibm.xsp.extlib.component.dialog.UIDialog = getComponent("dialogTarifeConfirm");
dialogTarifeConfirm.show();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
btnCreateNewDocument
your code should be placed:<xe:dialog id="dialogTarifeConfirm" title="Create New Document">
...
<xp:div styleClass="lotusDialogFooter">
<xp:button id="btnCreateNewDocument" value="YES (Create New Document)">
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="lotusForm"
execMode="partial" execId="btnCreateNewDocument">
<xp:this.action><![CDATA[#{javascript://Creating New Doc...
var docNew = database.createDocument();
docNew.appendItemValue("Subject", requestScope.subject);
docNew.appendItemValue("fieldName1", viewScope.fieldName1);
docNew.appendItemValue("fieldName2", viewScope.fieldName2);
docNew.save();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:link escape="true" text="No" themeId="Link.Action"
onclick="XSP.closeDialog('#{id:dialogTarifeConfirm}')">
</xp:link>
</xp:div>
</xe:dialog>
I hope this helps
Upvotes: 2