John's Development Blog

11 Oct 2014

I use working sets in Domino Designer all the time otherwise the Application Navigator becomes unbearable.You can also use working sets in the Package Explorer but unfortunately as standard they are not linked to the working set selected in the Application Navigator. Brad Balassaitis has previously blogged how to configure the Package Explorer and Application Navigator to use the same working set: XPages Tip: Select a Working Set in Package Explorer (and Navigator)

As I transition into doing more Java work in Eclipse I decided to use working sets there too. By default the Package Explorer in Eclipse does not display your projects grouped by their working sets although you can add new and existing projects into them.
To display working sets in the package explorer click the 'View Menu' button in the top right, then select 'Top Level Elements' and 'Working Sets'

I also find it very useful that you can add a project to multiple working sets.

2 Oct 2014

In my previous post I walked through creating a simple layout control as an OSGI plugin.
The next step is to deploy the control to designer this is where the set up we did in part 2 comes in.

Inside eclipse then right click the plugin then go to Export
Select 'Deployable plug-ins and fragments' and click next.
Ensure your plug-in is ticked then set the destination as 'Directory' and set that to be your newly created plugin directory, finally click finish.

Your plugin should now be available inside Domino Designer.
Inside Designer create a new XPage, now inside your controls palette you should see new category 'JMC Layout Controls'.

26 Sep 2014

Recently I have had a gentle nudge from a couple of people to continue my blog posts, as everyone can appreciate thinks occasionally fall be the wayside especially when children are about.

In my first post I discussed how to set up the eclipse environment for creating Domino OSGI Plugins and in the second how to configure Domino Designer ready install your plugins.

In this post I'm going to walk through creating a very simple plugin, a standard page banner/header.

Firstly you will need to create a new project:
File -> New -> Plug-in Project
Enter a project name, change the location if you wish and add to a working set if you like (I always do).
Click Next
Change the name if you wish and un-tick Generate an Activator and click Next
Un-tick Create a plug-in using one of the templates

You should now have a project open in Eclipse.

To create a component you will need use some of the built-in Domino libraries therefore we will need to add them as dependencies to the project.
To import the required libraries open the Manifest.MF file, open the dependencies tab and click add
Type com.ibm.commons into the text box then select the plug-in from the list and click OK
Now select the newly added plugin and click properties
Delete the minimum version and click OK
Now do the same again for 'com.ibm.xsp.core'

The next step will be to create some classes, one for the component itself, one for the renderer and one for the library extension point. We will also need to create some of config files.

To create the component class right click the src folder and click New -> Class
In the new class window enter a package name, name for the class and add a superclass 'javax.faces.component.UIOutput'
Click Finish

In your newly create class you will need to set a renderer and a family, in this example I have created static variables then set the renderer type in the constructor and and overridden the getFamily method.

We now need to create the xsp-config and the faces-config files. Some people like to store these files within a META-INF folder in the src folder personally I prefer to have them in the same package structure as the rest of the plugin.
First create a new package in the src folder, I'm going to call it 'com.jmc.xsp.example.layout.config'.
Then you need to create 2 new files inside this package; 'headerComponent.xsp-config' and 'headerComponent-faces-config.xml'.
The xsp-config file is used by Domino Designer to add the control.

The faces-config file will be used to map the control to its corresponding renderer. This done by matching the output from the control's getFamily and getRendererType methods to the
component-family and renderer-type in the file.

Finally we need to create a library class which is used when the library is loaded to find the names of the config files. The new class needs to have 'com.ibm.xsp.library.AbstractXspLibrary' as it's superclass.

Now we have the library class we can contribute it as an extension point.
Open the MANIFEST.MF file, go to the Extensions tab, click Add and select 'com.ibm.commons.Extension'. Click Finish
You should now have a new extension listed, click service underneath the new extension then add 'com.ibm.xsp.Library' to the type field, in the class field ad the name of your library class in my case 'com.jmc.xsp.example.layout.library.Library'. Now save your changes.

You should now have an Plugin ready to be deployed to a Domino Server and Domino Designer

19 May 2014

In my previous post I described how to initially setup eclipse in preparation for creating your own XPage plugins. This will then allow you to deploy your Plugins from eclipse and debug when necessary.

To use your own controls you will need to create a plugin and install this into Domino Designer and onto the Domino Server. My preference is wrap the plugin up into an update site and install as described in this article: How to install the new XPages Extension Library with the Eclipse Update Site database. One of the issues with the above is that if you are constantly making changes to the control (eg. adding new properties) you need to continually export them to an update site, import the new update into Designer and restart, which after a few times becomes frustrating.So to get around the issue i make a couple of changes to my local Designer configuration as described below.

Open your notes directory, navigate to the framework directory, create a new folder and name as you feel suitable (e.g. jmc-plugins). Inside the newly created folder create another folder called eclipse.

Next navigate to the framework\rcp\eclipse\links folder and create new text file named again as you feel suitable ensuring it has the extension ".link"(e.g. jmc-plugins.link)

Inside your newly created text file add the following: path=C\:/Program Files (x86)/IBM/Notes/framework/jmc-pluginsensuring the path is to your newly created directory.What the link file does is tells Designer to look in the new folder to load any additional plugins/features which will then allow you to export you plugin directly into this folder.Unfortunately this will not work just yet as Designer by default does not allow you to plugins in this way, to resolve this you need to edit the following filedata/workspace/.config/org.eclipse.update/platform.xml

Change the transient attribute on the config tag to false and replace all the instances of policy="MANAGED-ONLY" to policy="USER-EXCLUDE"

For these settings to take effect you will need to completely close Notes/Designer/Administrator and re-open. I have read that you need to use the following when restarting Designer using the command "designer.exe -RPARAMS
-clean". I can't remember doing this myself.

6 May 2014

Recently I have been writing some of my own XPage components, initially i began writing them inside domino in the nsf that was using them.I eventually i began to put some of the controls inside other nsfs, but as always i had to make some fixes enhancements to the bugs Features that I happened to code into the components. I then had to go back to the other databases and apply these enhancements.So, I decided it was time to write my own plugin to deploy the components to the server so they would be available to all applications also giving me one place to update.In the next series of posts I'm going to describe how i set up my environment to create plugins using eclipse.Part 1 - Downloading and Configuring Eclipse

Now we have everything we can start Eclipse and configure accordingly. When you first start Eclipse you will be prompted to choose your workspace. Change if you wish or just click OK.

Once inside eclipse go to Help -> Install New Software. When the Install window loads click Add to link to a new repository. Enter a name 'Domino Debug Plugin', click Archive and select the debug plugin update site you extracted earlier.

Don't bother restarting yet. Go back and install the XPages SDK as we did with the Debug plugin above:

Once the XPages SDK is installed restart Eclipse.Now we need to configure the XPages SDK. Goto Window -> Preferences and select XPages SDK at the bottom.Ensure you tick Automatically create JRE and fill in the fields accordingly

Click Apply.Next go to Java -> Compiler and drop the compliance level to 1.6 (assuming it's not there already). Click Apply.Go to Java -> Installed JREs and select XPages Notes JRE (This will not be here if you did not tick the box above)Go to Plug-in Development -> OSGi Frameworks and select Domino OSGi Framework. Click Apply.Finally we need to create a Target platform, fortunately this is easy with the XPages SDK installed.Go to Plug-in Development ->Target Platform and click AddSelect Template Notes Install Target

Click Next. Click Finish.Now select the Target we just created and click Apply.

7 Jan 2014

Recently i have been working on an application that requires a field with a limited number of characters (200 in this case).
However from a users perspective it is difficult to know the number characters currently used so I decided to display the number of characters:

As the text area changes the count is updated, if the limit is reached further characters are prohibited. This is achieved by using the key up to trigger a client-side javascript function:

The above was great; it uploaded the image and displayed it. However if you upload another image it still displays the first image which is exactly what i had told it to do:docApplicationDetails.getAttachmentList("Icon")[0].getHref()

To get 1 upload only I could have used this snippet posted by Sven Hasselbach
Unfortunately, this snippet was not suitable for me as it involves saving the document so I decided to use this:

This was also not suitable as the first image that gets uploaded gets named 'icon.jpg' but the next image is named 'icon_1.jpg'.

Finally, I decided the best approach would be to remove the first attachment before the second is uploaded and the way I decided to do this was using a validator. The validator is ran in the page lifecycle before the data model is updated (file is uploaded to the document).
This was the final result: