In this article I will demonstrate how to implement a cool notification technique using Pines Notify. This small (7k min) js library provides a wealth of flexibility and a feature set second to none. It can use multiple different CSS libraries (bootstrap, jQueryUI and others) so integration into your site is quick and simple.
Introduction
Pines Notify is a notification popup capability which is easily integrated into a website. Like most jQuery plugins there is a methods to instantiate the capability and the ability to pass in multiple parameters. There are certainly other popup style plugins but this is easy to grasp and the examples are very good.
We are going to look at how to make some complex function popups like these…

Demonstration
There are two demonstration pages this week
The first demonstration is a basic port of the Pines Notify buttons from the original example into an XPage.
The second demonstration shows how the Pines Notify could be used in a real application
Download
Click on the link to download the complete jQuery in XPages demonstration database (including Pines Notify).
Pines Notify
Pines Notify provides a basic shell for popup creation and the capability for multiple custom configurations. A “popup” by default is created on the top right of the screen and disappears after a fixed period of time. The the position, CSS, length of time shown, transparency, contents, callbacks and other features can be controlled through the use of parameters. There are too many to mention in one article but they can all be seen at the example website.

Adding Pines Notify to an XPage
The Pines Notify download contains the .js files (readable and minified) and a basic css file. These are easily added to our database as files in the WebContent folder.

Once we have added the js and css files to the database they can be added to our XPage as a resource(s)
<xp:this.resources> <xp:script src="js/jquery.pnotify.min.js" clientSide="true"></xp:script> <xp:styleSheet href="css/jquery.pnotify.default.css"></xp:styleSheet> </xp:this.resources>
jQuery UI and jQuery
Pines Notify uses the jQuery library and jQuery UI CSS for display. These are added to the XPage as additional resources
<xp:this.resources> <xp:script src="js/jquery-1.7.1.min.js" clientSide="true"></xp:script> <xp:styleSheet href="css/jquery.custom-theme/images/jquery-ui-1.8.18.custom.css"></xp:styleSheet> </xp:this.resources>
Using Pines Notify
Pines Notify has a basic format for activating. Here is a sample button from the website:
<button class="btn source" onclick="$.pnotify({ pnotify_title: 'Regular Notice', pnotify_text: 'Check me out! I\'m a notice.' });">Regular Notice</button>
In this format the button does not work correctly when added to an XPage as it causes a page refresh when clicked. To turn this into an functioning button we must use an <xp:button> like this one
<xp:button value="xPages Lower Timer" id="button1" styleClass="btn source"> <xp:eventHandler event="onclick" submit="false"> <xp:this.script> <![CDATA[$.pnotify({ pnotify_title: 'Regular Notice', pnotify_text: 'Check me out! I\'m a notice.' });]]> </xp:this.script> </xp:eventHandler> </xp:button>
The Pines Notify examples website gives us the code we need to create each button

And to convert this to our XPages button we just need to copy and paste this code and insert it into the <
Closing Notifications
By default all notifications can be closed before they fade out using the X in the notification
Stacking notifications
Pines Notify notifications always stack on top of each other, so you never have to worry about position or overlaying issues, they will organize themselves nicely.
Showing all notifications
By default there is a bar added to the screen which allows user to see the last and/or all previous notifications.

Working this into XPages functionality
Javascript alert boxes have been used since the start of the web but they require a user click and an unnecessary interaction from the user if the point of the notification is just that – to notify the user of something.
In our XPages applications we could potentially notify the user after:
- Successful REST update from the server
- partialRefresh completion
- form submission
- Pager completion
- General application workflow progress
- Validation failure
really the possibilities are endless and really up to you the developer.
Examples
My demonstration site examples page has illustrated a number of buttons taken directly from the website and I have also added some notifications to the other jQuery in XPages examples (linked in through the menu).
On my second Demonstration page There are 4 simple examples of real application uses for Pines Notify
Dojo Toaster Widget
On the XPages server without the need for jQuery you can use the dojo toaster widget to provide a notification capability. You should take a look at Chris Toohey’s well written article on Mastering the Dojo Toaster for XPages to get a comparison.
Thanks
To Alan Hurt for pointing me in the direction of this plugin 🙂
I tried to implement the pines notify in my xpages app.
I added the resource files to the webcontent folder and to the resources of my xpage.
When I try using the notify button I get an error : $ is not defined
When I put the exact same xpage to your jqinx.nsf it works.
What can be wrong ?
$ is not defined means that the system has not found jQuery and there are a number of causes and ways to find out the problem.
When you reference the JavaScript libraries in your XPages there is an importance to the order. You must make jquery the first in the list. In the jqinx.nsf I have added jquery-1.7.1.min.js to the theme of the database so it is always added to every XPage before any of the page resources. That probably explains why it works for you in the sample database.
You must check and make sure your path is correct. I use Firefox and the httpfox plugin to watch the page traffic – it will tell you when it is trying to load a file and the path is wrong (404 error).
View your page source – is the page attempting to load jquery.js in any way? If so copy and paste the URL in the source into your browser window – if you get a 404 error then figure out why jQuery.js is not on the path you are looking at – get the right path in the browser before you go back and re-code it in the XPage resource.
Please let me know if that helps and if not I will be happy to help you figure it out offline 🙂
Hi Marky,
Me again….I’m tryting to show notification(warning fact) on the top of my webpage, so I COPIED the resources from your db to mine directly,
they are
jquery-ui-1.8.18.custom.css under webcontet\css
and
jquery-1.7.1.min.js
jquery-ui.1.8.18.custom.min.js
jquery-pnotify.min.js under webconten\js
the notification come out indeed, but…it seems lost the css, I mean, I just can see the text, but no yellow backgroud and other effects。。。so what i miss? I even copy all the folder “custom-theme” to my db, still not work with ths style…
and one more question, what I’m doing now is to validation a date, I have to validation it via ssjs, so what can I do to call it from csjs? the ssjs will call a java bean script, such as buillbean.checkdate()….I know you wrote another article to discuss it, I do want to hear your suggestion about it, I mean, did I need do the ccjs call ssjs things? or if there have other way to validation the date and show user the warning message? thanks~
Sean.
Marky:
I build a same xpage in your demo db, and I compared with the page source, find some differents:
in your db’s xpages, there have
link rel=”stylesheet” type=”text/css” href=”/OA/jQinX.nsf/xsp/.ibmmodres/.css/css%2Fcustom-theme%2Fjquery-ui-1.8.18.custom.css&css%2Fjquery.pnotify.default.css”
but in my db, it becomes:
link rel=”stylesheet” type=”text/css” href=”/dsieyx.nsf/xsp/.ibmmodres/.css/css%2Fjquery.pnotify.default.css&mobile_wechat.css”
so that’s the reason why the style miss in my db,right? but….what caused it? I do copied all resources u mentioned,
Marky:
I find the reason is in your db, you use ur custom themes, once I changed it to the original theme, it’s the same with my own db, then I checked your xomino.theme, and find the
text/css
css/custom-theme/jquery-ui-1.8.18.custom.css
so is that means all xpages will load the css automatically….but how can I use it directly without your theme?
well, I will tried it now…will let you know the result…