Search
Categories
Tags
Latest Comments
« Adding XPages Controls to a View Panel's Column | Main | XPage Cheat Sheet #2 - DataSource and NotesXspDocument »
Tuesday
Nov102009

Working out the API for Xsp Classes in XPages

One of the biggest problems I have is interacting with the various components of an XPage programatically. It's not that I can't get hold of them, but it is that I don't know what classes they are from a Java point of view, and therefore don't know what methods and properties I have available to me.

So my solution is to first create an error. Say, for example, I want to programatically control a Pager control. I'll add a button to my XPage with an onClick event something like this:

getComponent("pager1").setStart(1);

I know this will fail, but if I have the default error page enabled then I'll get an error message like this:

And from the error message I can now tell that the object I want to talk to is of the class "com.ibm.xsp.component.xp.XspPager" and when I add that to the variable definition I'll get full type ahead of the API for that class in Domino Designer. So now I know that I can write something like this:

var pager:com.ibm.xsp.component.xp.XspPager = getComponent("pager1");
pager.gotoFirst();

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (2)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    Response: ogfzofkg
    ogfzofkg
  • Response
    Response: nypqrjfo
    nypqrjfo

Reader Comments (5)

cool tip, that's what you call Try and Error

November 10, 2009 | Unregistered CommenterFrank van der Linden

For what it's worth, the following syntax will also tell you the class of any control:

typeof getComponent("pager1")

So if you want to extract the class name without triggering an error, you can create a computed field and set its value to return the class name of another control via typeof.

November 10, 2009 | Unregistered CommenterTim Tripcony

Nice technique Matt! Thanks for sharing it....

-John

November 10, 2009 | Unregistered CommenterJohn Mackey

Other technique:

var file = getComponent("fileUpload1");
print(file);

you get in console the class

10/11/2009 13:36:08 HTTP JVM: com.ibm.xsp.component.xp.XspFileUpload@78c778c7

November 10, 2009 | Unregistered CommenterWesley Guisso

There is even a proper command for that :)

var obj = getComponent("XSPID");
_dump(obj);

November 10, 2009 | Unregistered CommenterVince Schuurman

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>