This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jun 7, 2012, 9:18 AM
8 Posts

Using SSJS in client side javascript script libraries

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 5
 I'm sure this must have been asked before but I'm obviously not using the correct search terms as I can't find the answer.
 
I'm writing some client side javascript in a script library which needs to use the IDs of certain controls.  I know about using elementid = '#{javascript:getClientId("elementid")}'; or even elementid = '#{id:elementid}'; but I don't seem to be having any success using this in a script library.  It doesn't look as though Domino is processing the SSJS before passing the script library to the browser so the script is rendered exactly as I wrote it.
 
Is it possible to do what I want in a javscript script library or am I limited to using this in the on-page scripts?
 
Thanks, 
Emily 
Jun 7, 2012, 9:46 AM
135 Posts
Re: Using SSJS in client side javascript script libraries
Hi,
 
I don't think that will work. Script Libraries are separate elements which can be used from other pages than XPages and probably that's why the SSJS in them is not evaluated. You will need to pass the IDs to script library in your XPage JS calls.
 
- Panu 
Jun 7, 2012, 1:52 PM
586 Posts
Re: Using SSJS in client side javascript script libraries
 I believe Panu is correct on this.  Don't try to figure out the id inside the function in the script library.  Do that from  the xpage or custom control and pass it into the function.
 
 
Jun 7, 2012, 1:58 PM
8 Posts
Re: Using SSJS in client side javascript script libraries
Thank you, both, for confirming this for me.  
 
I suppose the main idea of script libraries is to facilitate reusable scripts, in which case it makes no sense to be using ids of specific objects within the script library.  This is another situation where I need to change the way I think about how to connect the various design elements.
 
A big part of the problem in this case is that I tend to go straight for the script library design element as I hate writing script into the design page which only ends up using about a quarter of the screen. I need to think more about the correct way to do this from a coding point of view, rather than from my preferences in using the IDE!
 
Emily. 
 
 
Jun 7, 2012, 6:30 PM
586 Posts
Re: Using SSJS in client side javascript script libraries
Emily, 
 I guess I'm not sure what you mean about the design page being a quarter of the screen.
 
Are you talking about the Source pane?  You can double click the tab to go full screen for the most part. 
 
Are you talking about the value for a field or event handle code?  There's a button to launch where you can code in an expanded window and you can resize that appropriately.
 
Let me know here or drop me an email if I'm missing something. 
Jun 8, 2012, 7:49 AM
8 Posts
Re: Using SSJS in client side javascript script libraries
 I'm talking about writing things like button code on classic Notes/Domino forms where you have the form design open at the top and then the bottom part of the screen is split into the form events and the programmer's pane.  Old school!  I never liked expanding the programmers pane to cover the form design as I would often be switching between buttons or actions and would find it irritating to be expanding and contracting it all the time, therefore I would always go straight for a script library for writing anything other than a few lines of code.  
 
I'm aware that things are better for that in xpages design elements, although I do find entering code into a modal dialogue box a bit annoying.  That's just my personal taste though.  Like I say, these are things which I'm going to have to think about in different ways in order to fully embrace the future!
 
Thanks David, 
 
Emily 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal