2

I am using the sbt accessing different pieces of data from Connections ( 4.5 ) using xPages on Domino 9.01 FP2 HF384.

When I execute the code below I get an error the method can not be found. Yet this works fine on the playground when pointed to my connections instance.

Any thoughts on what could be wrong?

<xp:this.value>
        <![CDATA[#{javascript:
            var communityService = new com.ibm.sbt.services.client.connections.communities.CommunityService("connectionsSSO");
            var communityId = "39a2302a-f07f-425d-bfcb-54f1b9564268";
            var startDate = new Date();
            startDate.setFullYear(2012,01,01);
            var events = communityService.getCommunityEvents( communityId, startDate.toUTCString());
            return events;
        }]]>
</xp:this.value>
Serdar Basegmez
  • 3,355
  • 16
  • 20
Bitwyse1
  • 339
  • 3
  • 18
  • I think when you use the js code, you aren't actually using pure JS approach, I think it's actually java. as a java snippet that code doesn't exist, I suggest wrapping the code - script - element... hopefully others can jump in and answer. – Paul Bastide Mar 06 '15 at 00:30

1 Answers1

2

Paul is right.

IBM SBT has Java SDK and JavaScript SDK. However JavaScript SDK is intended to be used on browser-side. It basically wraps what you want and send it to the proxy service on the server, which acts like a bridge between your browser and the remote Connections instance.

Server-side JavaScript in XPages is a programming model that works on the server-side. It can run Java code as well. So you can only use Java SDK on the SSJS, not JavaScript.

Java SDK has no direct way to receive community events. So I suggest using client-side JS code to retrieve that information. There are a couple of ways to add CSJS code into XPages. The simplest one is to use <xp:scriptBlock>.

<xp:scriptBlock id="scriptBlock1" type="text/javascript">
   <xp:this.value><![CDATA[dojo.addOnLoad(function() {

   // Here, you can use the JavaScript snippet from the playground.

})]]></xp:this.value>
</xp:scriptBlock>
Serdar Basegmez
  • 3,355
  • 16
  • 20
  • Thank you so much Serdar. I do not do very much client side javascript so I am not as familiar with the syntax on how to implement the code and then call the function... I will give it a shot. – Bitwyse1 Mar 06 '15 at 21:20