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



May 29, 2012, 11:01 AM
15 Posts

How to write a javascript function in xpages

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5
  • Role: Developer
  • Tags:
  • Replies: 3
 Hi,
 
I have tried millions of times to run a small javascript function in an Xpages and tried to show the output via web browser(Firefox). 
Unluckily, i could not have the output as I expected. I have referred javascript tutorials through w3Schools, as most of the developers do. Finally i came for a conclusion, which is "the way of working with javascript in Xpages totally different from as we are done in HTML pages". Am I correct? 
 
Can anyone help me? Please attach some references if you can.
 
Thanks. 
May 29, 2012, 11:32 AM
170 Posts
Re: How to write a javascript function in xpages
 Use the Output Script element. it's not visible so you have to use Other -> Insert (it's located at the top of the Control tab)
 
And when you have added this to the page you have to add the client javascript to the all properties -> value  
 
/Fredrik 
 
May 29, 2012, 12:09 PM
126 Posts
Re: How to write a javascript function in xpages
No its not really different from HTML at all. Also there is nothing stopping you from adding regular HTML into your page if need be
 
<script>....</script> 
 
You can use any of the methods / functions / controls that XPages provides with it. 
 
If your writing functions the easiest way would be to add a javascript library to your application and add it too your page (almost exactly the same as added a javascript file to a HTML page), just because its good to separate out the code. If you post an example of what your trying to do I can take a look at it but your original post is quite vague. Below is an example of a client side function being called inside a button and modifying a label.
 
<xp:label id="testLabel">
</xp:label>
<xp:button value="test" id="button1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script>
<xp:executeClientScript>
<xp:this.script><![CDATA[
function test(str)
{
var lbl = dojo.byId("#{id:testLabel}");
lbl.innerHTML = str;
}
 
test("example");
]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script>
</xp:eventHandler>
</xp:button> 
May 31, 2012, 8:34 PM
15 Posts
Re: How to write a javascript function in xpages
To write javascript function in xpages you should use script libraries where all the commands for writting server side javascript are given on left side.This is mostly same as lotus script. And after coding include that into the xpage through resources.

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