2
votes

Accessing controls values, what is the recommended way to use ?

document.getElementById(...) or XSP.getElementById(...)

2

2 Answers

3
votes

The XSP object acts a "wrapper" and would hide implementation details (browser incompatibilities, etc.) for you, therefore I would prefer the use of XSP.getElementById(...):

The XSPClientDojo library defines a global XSP object which exposes some JavaScript functions to the XPages runtime. As its name suggests, XSPClientDojo utilizes the Dojo JavaScript library, however other implementations may be developed in the future (for example, when supporting handheld devices).

1
votes

document.getElementById(...) places the reliance on browser implementation. XSP.getElementById(...) places the reliance on the IBM Dojo extension and IBM support.

The same rules hold for any of the XSP.... methods. If browsers changes should ever affect it, IBM code will be updated and as long as your server is on the current release and fix packs you will not need to make changes to your application. So as with relying on any framework, it comes down to whether you are willing to keep the framework up to date to leverage the extra layer of abstraction.