1

I wanted to know if it's possible to handle notes views and document collections via client side scripting in Xpages?

The story so far....I am building a HR system that includes a full absence section (holidays, sickness, other absence etc). I have coded a button in the notes client that creates an Excel spreadsheet showing a calendar of the last 12 months absences for the current user based on the absence documents (getview, getalldocumentsbykey into collection). It loops the collection using various fields (incuding multi value fields) in each document to calculate absence length, full/half days etc and marks them on the sheet in different colours with hyperlinks to access the documents.

It also calulates other things like the Bradford Factor rating and does calculations around the users working days.

Anywho, I've been challenged to get the entire system working in a browser, removing any need for the notes client, so....back to my original question, I need to be able to get a collection of documents from a notes view via a key that I can then access the field on via client side javascript.

Is this possible? I can provide more info if required...

  • 3
    You can do all this using XPages (e.g. using server-side JS or using Java). Are you using XPages already for this solution? – Per Henrik Lausten Dec 03 '12 at 16:05
  • I'm sure most of this could also be done with a LotusScript web agent even without xPages, but the critical question is what API you are using to put the data into Excel. Can you show us some of the actual code? If the API for Excel must be client-side, then DXL may be the best option -- but I don't want to take that as a given. – Richard Schwartz Dec 03 '12 at 16:44
  • The lotusscript version is using: `Set xlApp = CreateObject("Excel.Application")` to create the Excel object and build on it from there. The CSJS version is using: `var xlApp = new ActiveXObject("Excel.Application")` to achieve the same result. I'm assuming it HAS to be client side to initiate the Excel object on the users machine as opposed to popping Excel open on the server? @PerHenrikLausten @RichardSchwartz – CodenameSnugs Dec 03 '12 at 16:58
  • Also the code is quite large, happy to email it if that helps? – CodenameSnugs Dec 03 '12 at 16:59
  • Also just to clarify, I'm not trying to create an Excel file, I'm just trying to open Excel and create the sheet so it's visible to the user. Saving it is not required, it's just for viewing. – CodenameSnugs Dec 03 '12 at 17:10
  • No thanks on the emailed code. That goes against the spirit of this site, which is to share information with everyone who sees the thread, not just with a few who jump in early. In any case, you've given an adequate description now. I believe there's actually a way to create data on the server side and then send it down to the browser with the correct MIME type so that the client will open it in Excel. See http://www.botstation.com/code/view2excelweb.phpfor a possible sample. (I haven't tried verified this code, but I've seen other references to the technique.) – Richard Schwartz Dec 03 '12 at 19:39
  • 2
    I guess the other question would be why, if saving in Excel format is not the real goal, are you bothering with Excel? Why not just program your XPage to create a nice row/column display that users can view? – Richard Schwartz Dec 03 '12 at 19:47
  • @CodenameSnugs: Do you need to fill in an existing Excel Template, or doc you have to generate the excel sheet "manually"? – Sven Hasselbach Dec 04 '12 at 09:46
  • I guess the 'why' is because I originally created the script on the client and presenting the data in Excel was very easy and neat, however replicating this on the web turns out to not be so easy! @RichardSchwartz I'm going to look at you botstation link today, that looks prommising and may mean I can just modify the original script to do that instead of pushing it directly into Excel... – CodenameSnugs Dec 05 '12 at 09:19

4 Answers4

1

Have you considered the Notes Browser Plugin? It is supposed to let you run the Notes Based Apps through the browser without modifying the code.

Here is a write up about it

DaBaer
  • 204
  • 1
  • 7
1

You can access all Domino objects from client side JavaScript vith Java and CORBA. You just need a small applet that returns Session to javascript. Here are instructions from Designer help:

http://www-12.lotus.com/ldd/doc/domino_notes/rnext/help6_designer.nsf/9/0d05bb3cec358f7085256c54004bdbff

However as Per suggested nowadays a combination of client and server side Javascript in XPages are usually used instead of CORBA. Domino Data Service is the latest way to get data from server to (for example) client side javascript.

You may also want to take a look at Apache POI with which you can create Excel files in server side. ActiveX works only in IE althought there are plugins to get it working on other browsers.

edit

What I usually do with "combination of client and server side Javascript" is to use dojo.xhrGet (or xhrPost) in client side. On server I have an XPage (earlier agent) which collects the data and returns it in JSON format.

  • Panu
Panu Haaramo
  • 2,932
  • 19
  • 41
  • CORBA looks promising, though I know nothing about Java. It looks like I need to create an applet containing `import lotus.domino.*; public class dummy extends AppletBase(){}` ? Do I then add that as a resourse to the Xpage? (There doesn't seem to be an option for Java).. @Panu – CodenameSnugs Dec 04 '12 at 09:25
  • Yes and the applet needs to return the Notes Session. The applet code is under the "Example" link on the page I linked. Add the applet with Designer to: Recources / Applets. Load the applet on the page using HTML: https://eyeasme.com/Shayne/HTML5_APPLETS/. In this solution CORBA/IIOP needs to be enabled on server which it might not be as default. – Panu Haaramo Dec 04 '12 at 10:55
  • You could do that and compile it with javac.exe. Probably it's easier to create a Java project in your Designer Eclipse and go from there. – Panu Haaramo Dec 04 '12 at 11:39
  • Not knowing Java I'm sturggling a bit here....I managed to compile the applet by setting CLASSPATH to point at a couple of required Notes jar file (as per instructions), however it would only compile if I removed the brackets after AppletBase in the second line. Leaving them in it just errored (expecting { ). I added the applet through resources as described and used the HTML example to add the code to the page but the applet errors saying it can't find a class called 'dummy'. This is the only method that's got me anywhere so far so any further help would be greatly appreciated! @Panu – CodenameSnugs Dec 04 '12 at 16:45
  • Also several options have now vanished from my Resources menu in Designer, all that's left is Images, Files, Style Sheets and Themes! So I can't actually get to the applet area at the moment either! – CodenameSnugs Dec 04 '12 at 16:46
  • Looks like there is a bug in the sample code. Remove (), not {}. You can set what design elements are shown in Designer from Preferences -> Domino Designer. – Panu Haaramo Dec 04 '12 at 17:58
  • I really like using the Apache POI, though there are some things it can't do yet (sort, for example). – David Navarre Dec 04 '12 at 21:44
1

Edited to put emphasis on &ReadViewEntries and add detail

Doing it purely on the browser-side would probably best be done by fetching DXL or JSON using the &ReadViewEntries URL command, and then writing Javascript to process the data and do the equivalent of the CreateObject call locally. You can find the doc for &ReadViewEntries here. (@Panu has already mentioned DDS, which is also a good idea.)

Or see here for some sample code that shows a technique that a Domino web agent written in LotusScript can use to create data that will be sent to the browser with a content-type header that causes it to be opened in Excel. I haven't verified this particular code, but I've seen other references to the technique. This particular code might not give you as much control as you want -- e.g., colors and links, but I think it would also be possible to actually generate the data as XML in the xlsx format and send that down similarly.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
1

I think you should go for REST. In Domino, it can provide data from views/documents in JSON format which you can use in client side JavaScript natively. For more info try searching google and ddwiki, for example this tutorial video.

Frantisek Kossuth
  • 3,524
  • 2
  • 23
  • 42