XPages JavaScript utility function of the day

Yesterday and today I’ve been spending some time doing some XPages coding for a customer project and after spending quite some time doing Java plugin development I’m amazed of how easy XPages are. Don’t get me wrong – there is still work to do for the XPages team but it’s a joy to work with XPages and coding in JavaScript is just – well – flexible and fun.

One of the real joys of JavaScript is it’s dynamic nature and that it allows one to really cut down on the boilerplate and repeated code. For one I spent a lot of key pressed getting field values from backend documents in server side JavaScript. Instead of repeating the same ol’ Document.getItemValueString(String) over and over again I did a neat little shortcut. Since I needed all items from a document I just created a utility function to JSONify a document to make it easier to access. The method is below.

var jsonifyDocument = function(doc) {
   var result = {};
   if (!doc) return result;
   var item;
   for (item in doc.getItems().toArray()) {
      result[item.getName().toLowerCase()] = item.getText();
   }
   return result;
};

So now instead of writing doc.getItemValueString all the time I can now just do property-like access to field values (“Heading” and “Description” are fields on the document).

var jsonDoc = jsonifyDocument(doc);
jsonDoc.heading + " (" + jsonDoc.description + ")";

I also wrote a nice little Dojo-like mixin function to make my XAgents easy to configure. But that’s for another day.

Save the date: XPages Documentation Discussion

I found this via the LotusUserGroup.org newsletter and I found it worth passing along.

On Monday, November 8th, give a shout out to the documentation team for Lotus Domino Designer. The team is looking to get your feedback on how helpful you find the Domino Designer User Guide (XPages) Help and will be moderating a forum on the topic at
LotusUserGroup.org/forum for you to shout out your comments
And observations.

The XPages Help provides information that is necessary for
developing web applications using the new XPages technology
available in Domino Designer. Do you like the newly added
controls and properties reference sections? Have some feedback orsuggestions on the usability of the documentation – content that works well, content that needs improvement? This is your chance to really impact the XPages documentation content.

So mark your calendar. Bob Harwood, the Information Development (ID) Lead for Domino Designer, the Domino Designer ID team, and Cara Viktorov, ID Usability Feedback Lead, will be moderating the forum, live, the week of November 8, 2010. Plan to join in and ask questions, share experiences, and collaborate about Domino Designer Help.

Date: November 8, 2010
Forum: http://www.LotusUserGroup.org/forum

What is new in 8.5.2 for XPages

Lotus Notes/Domino 8.5.2 is out and the other day I was hosting an XPages training session so I thought a little bit about what’s new with XPages. Of course XPage ninjas like Matt has already written about it (Matt White: What’s new with XPages in 8.5.2) but as I was reading up I found some links I wanted to highlight. Most info may be found on the IBM wiki.

  • onClientLoad Event. Its now possible to add scripts in the events to be executed when the page is submitted or this panel or some containing panel is partial updated.
  • Extensions API
  • Two new Global Objects for Server Side JavaScript, sessionAsSigner (open a session using the signer rights) and sessionAsSignerWithFullAccess(open a session using the signer rights, while giving it full access to the data)
    • sessionAsSigner – Assigns credentials based on the signer of the of XPages design element. The session is restricted by the application’s ACL and the security tab of the server’s Domino Directory entry.
    • sessionAsSignerWithFullAccess – Assigns credentials based on the signer of the of XPages design element and allows full administrative access to the application’s data. The signer must have the right to such access or the session is not created.
  • New resource xp:headTag – this allow you in an easy way to put stuff into the header of a XPage
  • XPages ECL to Permissions updated to include more Java Permissions
    In V851 of XPages, security for executing Java code in XPages in the Notes Client was very restricted. For XPages V852, the Java Permissions managed by the XPages ECL settings have been broadened to be similar to the set of Java Permissions allowed by Java Agents and to bring a level of equivalence between Java Permissions allowed for XPages on Domino Server (Unrestricted) and XPages in the Notes Client. For example, in V851 the ECL Network permission only covered the Java SocketPermission, now it covers NetPermission and other related Java network permissions.
  • Referencing a Managed Bean from JavaScript now supported in XPiNC. This fixes a bug where a Managed Bean, first referenced in JavaScript (which triggered the creation of the Bean) caused a security exception. The workaround was to first have this Managed Bean referenced and created as a DataSource (referencing the Bean from then on was fine). This bug is now fixed.

Announcing the Lotus XPages Cup Competition

Visit the Virtual Innovation Center (VIC) to learn about the “Lotus Building Collaborative Applications with XPages Cup Competition” running from 27 September to 29 October, 2010. Take this opportunity to learn about the latest XPages enhancements built on the breakthrough innovation started in Lotus Notes 8 and Lotus Domino 8. The competition is open to all IBM Business Partners and there is no charge to participate.

Register for the competition

Out just in time for Lotusphere!

While ordering some stuff on Amazon today I stumbled over a nice book that is due out 21 January 2011. Apparently Martin (Donnelly), Mark (Wallace) and Tony (McGuckin) of IBM Lotus Domino XPage is writing a book about XPages and how to get going using a step-by-step approach. How nice.

Mastering XPages: A Step-by-Step Guide to XPages Application Development and the XSP Language

The Lotus Information Development Center (IDC) is looking for users

The Lotus Information Development Center (IDC) is looking for users to participate in XPages technical content and wiki usability evaluations coming up in October! In a usability evaluation you provide feedback directly to the Lotus IDC team about the documentation (help, wikis, etc,) for specific products or services. This is a great opportunity to share your thoughts and opinions with the people who create Lotus product documentation and wikis.

The team needs usability participants for the following evaluations: For this XPages technical content usability evaluation, the IDC team is looking for developers who are new to using XPages technology in their application development tasks but may have used Designer before the introduction of XPages. Familiarity with the legacy Notes application development model is a plus.

If you are interested in participating in any of these usability evaluations,
please contact the Lotus IDC team by clicking here: http://budurl.com/amwz

Provide your email address and the usability evaluation(s) you would like to participate in, and someone from the IDC team will contact you. Evaluations will be done via phone and web conference. Be heard and help improve the usability of Lotus technical content! The team looks forward to working with you!

XPages workshop

Today and tomorrow I’ll be at a XPages workshop with Tim Clark at IBM in Lyngby. Should be fun – probably not a lot of new stuff but it will be interesting to see how others teach XPages.