203 Lotus blogs updated hourly. Who will post next? Home | Blogs | Search | About 
 
Latest 7 Posts
A more direct way of creating an Outlook mail item from the Notes client
Wed, Nov 1st 2017 4
Sending an automated mail using Outlook from a Notes agent
Tue, Sep 12th 2017 3
Breweries and tap rooms for #MWLUG
Sat, Jul 29th 2017 2
So where can I go for dinner near #MWLUG?
Thu, Jul 27th 2017 1
Creating a meeting notice in Outlook from the Notes client
Fri, Jun 23rd 2017 1
Getting email addresses from the Notes address book
Wed, Jun 21st 2017 2
Progammatically opening a mailto link from the Notes client
Fri, Jun 2nd 2017 5
Top 10
Exporting from #XPages to Excel without Excel, Part 2
Thu, Sep 26th 2013 9
Configurable notification agent in #OldNotes
Thu, Sep 25th 2014 8
Sample database for #Excel exporting from #XPages
Mon, Feb 24th 2014 7
Dirty pages and keeping users on them in #XPages
Wed, Apr 16th 2014 7
Exception avoided in FTSearchSorted in #XPages
Mon, Aug 25th 2014 7
Are you sure? Asking for confirmation in #XPages
Wed, Sep 17th 2014 7
Copying property definitions for custom controls in #XPages
Thu, Mar 10th 2016 7
Java still not refreshing correctly in #XPages 8.5.3 UP 1
Mon, Nov 4th 2013 6
Simple dialog returning a value to your #XPages
Wed, Jul 16th 2014 6
Exporting to Excel using Queries in #Xpages
Thu, May 15th 2014 5


Are you sure? Asking for confirmation in #XPages
Twitter Google+ Facebook LinkedIn Addthis Email Gmail Flipboard Reddit Tumblr WhatsApp StumbleUpon Yammer Evernote Delicious
David Navarre    

Often, we want to confirm with the user that they actually want to save or submit a document in XPages. I thought it would be very simple to customize the server-side simple action ‘confirm’ to include client-side data that the user had just entered, but that was not yet saved to disk.

So, I had what I thought was some simple and straight-forward SSJS:

<xp:confirm>
    <xp:this.message><![CDATA[#{javascript:var baseText = "Are you sure that you want to set the exchange rate for ";
        var effectiveDate = getComponent("effectiveDate").getValue().toString();
        var localCurrency = getComponent("localCurrency").getValue();
        var exchangeRate = getComponent("exchangeRate").getValue();
        return baseText + localCurrency + " to " + exchangeRate + " as of " + effectiveDate + "?"; }]]>
    </xp:this.message>
</xp:confirm>

I posted my question on StackOverflow and Paul Withers pointed out that I wasn’t going to get what I was looking for….

You’re computing SSJS to pass to a CSJS confirm() message. I would expect it to display values at the last refresh, not values just entered by the user. If you want the latest values, I think you’ll need to access them via CSJS.

So, I made the classic mistake of failing to know whether I and my data were client-side or server-side. Thus, my getComponent commands were getting a handle to the last version of the server-side component, not what the user just entered on the client-side. So, I needed to move back to the client-side to display client-side values. Fortunately, I remembered that if your client-side javascript evaluates to false, the server-side script never executes.

<xp:eventHandler event="onclick" submit="true" refreshMode="complete"
        immediate="false" save="true" id="eventHandler3">
        <xp:this.script><![CDATA[var baseText = "Are you sure that you want to set the exchange rate for ";
            var effectiveDate = document.getElementById("#{id:effectiveDate}").value;
            var localCurrency = document.getElementById("#{id:localCurrency}").value;
            var exchangeRate = document.getElementById("#{id:exchangeRate}").value;
            return window.confirm (baseText + localCurrency + " to " + exchangeRate + " as of " + effectiveDate + "?");]]>
        </xp:this.script>
        <xp:this.action><![CDATA[#{javascript:exchangeRateDoc.save();
    context.redirectToPage("/pro_exchangeRate_view.xsp")}]]>
        </xp:this.action>
</xp:eventHandler>

The key to the client-side javascript is to make sure you return the value of that window.confirm at the end. In my initial attempt, I didn’t return the value and my testers pointed out to me that my ‘Are you sure?’ was just taunting my users. It would ask the question, but it ignored the response. Clicking OK would save it, as intended, but clicking Cancel would ALSO save it! Talk about ignoring user input!

Hopefully, my mistake will prove instructive in your attempts to find your way in XPages…..




---------------------
http://lostinxpages.com/2014/09/17/are-you-sure-asking-for-confirmation-in-xpages/
Sep 17, 2014
8 hits



Recent Blog Posts
4
A more direct way of creating an Outlook mail item from the Notes client
Wed, Nov 1st 2017 3:54p   David Navarre
A
3
Sending an automated mail using Outlook from a Notes agent
Tue, Sep 12th 2017 11:14p   David Navarre
A
2
Breweries and tap rooms for #MWLUG
Sat, Jul 29th 2017 4:49p   David Navarre
A
1
So where can I go for dinner near #MWLUG?
Thu, Jul 27th 2017 10:02p   David Navarre
A
1
Creating a meeting notice in Outlook from the Notes client
Fri, Jun 23rd 2017 5:23p   David Navarre
A
2
Getting email addresses from the Notes address book
Wed, Jun 21st 2017 5:50p   David Navarre
A
5
Progammatically opening a mailto link from the Notes client
Fri, Jun 2nd 2017 9:35p   David Navarre
A
3
What good is the internet of things to people who don’t have internet?
Tue, Feb 21st 2017 8:36p   David Navarre
A




Created and Maintained by Yancy Lent - About - Planet Lotus Blog - Advertising - Mobile Edition