Archives for the ‘XPages’ Category

3 Feb 2014
3

Slides and Info for Worklight Session at IBM Connect 2014

Firstly, a big thanks to everyone who attended our session on “IBM Worklight and XPages” at IBM Connect 2014 last week. It was great to see so many people turn up, especially on the last day of IBM Connect.

Below are the slides to the IBM Worklight Session, which will be available on SlideShare and for download. I will be releasing a video on this topic and will submit it through David Leedy’s NotesIn9 VideoCast (Hopefully next week still). I will also have the source code available for download when submitting the video.

Thanks once again and see you all online.

Cheers
John
29 Nov 2013
2

DanNotes Session Slides: Appcelerator Mobile and XPages

Here are the slides for my 1 session at DanNotes this week: Appcelerator Mobile. The Doppelgänger to XPages.

I cleaned it up a bit. Sadly there were 2 live demos, but I will publish more content around this soon enough.

I will submit my other slides early next week and will also be blogging about my Denmark trip soon enough.

Enjoy :)

26 Oct 2013
0

XPages Tip: Comparing a value in your XPages with backend data

I forget sometimes that many who have taken the path of XPages, are not necessarily existing Domino Developers who understand the Domino Object Model. This is a quick tip on how to take a field value from your XPages App, and compare it with data inside a Notes Database, and more specifically, a Notes View.

The Back-End Database

Let’s say you have a Notes Database with a view called “Fruits“. This view has 1 column called “Fruit Name” and is sorted in ascending order. Inside this view you have a few Notes Documents listed based on the following fruits captured:

FuitsViews

The XPage

Next, you have a very simple XPage with a Text Field called “inputFruit“, where a user will enter a fruit name of their choosing. The XPage also has a button called “Submit” and calls the following Server Side JavaScript Function – checkFruits();

FruitsXPage

The JavaScript Function

Here we create a JavaScript Function called checkFruits(), which will use the value entered and check if it exists in the Notes Database:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function checkFruits(){
   //Set our variables
   var doc:NotesDocument = null;
   var view:NotesView = database.getView("Fruits"); //Get a Handle on the Database View
   var key = getComponent("inputFruits").getValue(); //Get the entered value
 
   //Check if fruit entered exists
   doc = view.getDocumentByKey(key, true) //The 2nd parameter 'true' means 'Exact Match'
   if(doc !== null){
      print("The Fruit Exists");
   }else{
      print("No Fruits Founds");
   }
 
   //A JS Function should always return something
   return true;
}
Hope this helps :)
John
8 Oct 2013
6

Connect to a Notes Database on a remote Domino Server via SSJS

The other day I found myself needing to access a Notes Database on a Remote Domino Server via SSJS, but for some reason every one of my attempts failed miserably. No error messages written to the Console, no warnings, nothing.

Let’s quickly create a scenario

  • You have 2 Domino Servers: Server1/ACME and Server2/ACME.
  • On both Servers you have a Notes Database called “Test.nsf”.
  • On Server1/ACME you have a Notes Database with an XPage that calls the following SSJS:
1
2
3
4
5
6
7
var db:NotesDatabase = session.getDatabase("Server1/ACME", "Test.nsf");
 
if(db.isOpen()){
   print(db.getTitle());
}else{
   print('Cannot Open Notes Database');
}
  • Now, in the above example, you are trying to access a Notes Database on the same Server. The above code will successfully connect to the Notes Database and print the Database Title to the Server Console.
  • Next up, you have the following code that runs on the same Server:
1
2
3
4
5
6
7
var db:NotesDatabase = session.getDatabase("Server2/ACME", "Test.nsf");
 
if(db.isOpen()){
   print(db.getTitle());
}else{
   print('Cannot Open Notes Database');
}
  • In this example, you are trying to access “Test.nsf” on Server2/ACME, from a Script that’s running on Server1/ACME. This code will fail and will not provide you with any error message. The NotesDatabase Object will simply remain null.

The Reason

In all my years of developing Notes Applications, I never came across having to connect to a Database on a different Server. The reason the connection fails, is because Server1/ACME is not listed as a Trust Server in Server2/ACME’s Server Document in the Domino Directory.

The Solution

To resolve this issue is simple. The difficult part was finding the problem. If you have access to the Domino Directory on Server2/ACME, do the following:

  • Open the Domino Directory (Server Address Book) on Server2/ACME.
  • Under “Configuration”, click “Servers”, then click on “All Server Documents”.
  • Double click on the Server Document you want your code to connect to. (Server2/ACME in this example)
  • Under the Security Tab, in the bottom left section, there is a field called “Trusted Servers”.
  • In my scenario, this field is empty. Following this example, I would add “Server1/ACME” to this field.

Blog1

  • Save and Close.
  • Restart Server2/ACME.

Once you’ve restarted, your code will successfully connect to “Test.nsf” on Server2/ACME.

Till next time….cheers :)
John
10 Jul 2013
2

XPages Video Tutorial: Signing a Notes Database using Java

In this video tutorial I show you how to sign a Notes Database using the Server’s ID via Java Code.

In Lotus Notes version 6, IBM introduced a new method for the NotesDatabase Object called “sign()”. this allowed you to sign either the current database or another database using your current Notes ID. The only issue with this is that the Sign Request would only work if triggered manually inside the Notes Client.

For XPages development, this becomes an issue because you cannot perform a NotesDatabase.sign() on the front-end of your XPages Application.

So without further adieu, here’s the Video :)

Cheers
John