IBMSBT Playground gets a face lift

I noticed a couple of days ago that the “face” of the IBM Social Business Toolkit “playground” on the greenhouse site has undergone a face lift.

https://greenhouse.lotus.com/sbt/sbtplayground.nsf

This image was taken from the site March 4th 2015

s16

 

and this is how it looks today (March 22nd 2015)

s1

 

Not an improvement in this developers opinion because now I have no reference point as to the section I am looking at. Not a problem if you clicked in there – but if you bookmarked the URL you are if for a world of confusion.

An example of not considering the User Experience.

 

XPages and Java, starting over, again…..Hello World

OK to set the stage for what may just be about to happen – blogging is a form of self documentation for me. If I write it – it helps me remember it. I have said this before (multiple times) and failed, but I need to learn Java. It will probably fail again, let’s not kid ourselves, we all know Marky’s preferred language of choice (*coughs politely*). But I want to properly wrap my head around IBM Social Business Toolkit, and not just learn the limitations of the JavaScript API. To do this I need to learn Java and execute on it. So no promises, but we may get some blog posts on IBMSBT and my learning the Java way.

So with the help of Toby, the mockery of Brad and Kathy and the adulation of Eric, we will begin.

All of this code will be done in R9.0.1 (something)

Hello World (part 1)

1) Create a new Java Class in your database

There are apparently multiple ways to do this but I just went to the Java elements and clicked on the New Java Class button

j1
from the resulting popup enter a package name – in this case com.xomino.sbt, and the name for the new class, HelloWorld

The normal format for naming convention is

  • Package names are lower case and look like a website URL except backwards
  • Classes are Propercase

j2

 

Click OK and a new Class is created in Designer

j3

and the crowd went wild……well ok maybe not but I know Paul and Russ are laughing their butts off right now.

2) Create a new XPage (xHelloWorld.xsp)

In there I am going to create a button which when clicked will display hello world on the screen. To do this I am going to need a button and a computed field.

When the button is clicked I will set a viewScope variable and refresh the field.

The field is bound to the viewScope variable which I hope to set in the Java code…..Clicking the button will call the com.xomino.sbt.HelloWorld.setMessage() method, which will set the viewScope variable value.

<xp:button value="Click me" id="button1">
	<xp:eventHandler event="onclick" submit="true"
		refreshMode="partial" refreshId="aWrapper">
		<xp:this.action><![CDATA[#{javascript:com.xomino.sbt.HelloWorld().setMessage();}]]></xp:this.action>
	</xp:eventHandler>
</xp:button>

<xp:div id="aWrapper">
	<xp:text escape="true" id="computedField1"
		value="#{javascript:viewScope.message}">
	</xp:text>
</xp:div>

Once the viewScope variable has been set the aWrapper will be refreshed and I will see my value.

The class looks like this

package com.xomino.sbt;

import com.ibm.xsp.extlib.util.ExtLibUtil;

public class HelloWorld {

	public static void setMessage(){

		/*This is how you get XPages scopes in Java */
		ExtLibUtil.getViewScope().put("message", "Hello World");

	}
}

To enable the use of ExtLib code you must make sure the box is Checked in the database XSP properties
j4The output

helloWorld

 

In the dumbest way, this has made me very happy 🙂