I have spent the last week creating my own extension library and adding my viewpicklist and loading masks controls to it. I had lots up help because i was lost. So here are the steps i followed to get there.

1. Download the xsp starter kit from openntf.org
2. Watch Notesin9 number 64 by Tim Tripcony

Those two steps will get you a library and how to copy an existing control into your library.

Now my custom controls had css, images, and a client side js file with them. I didnt want to have to copy those to each database to use them so i had to fins a way to include the resources. One reason i told you to download the xsp starter kit was it has some classes to handle resources.

I added a new folder to my plugin project called resources, under that i had img and styles and js folders( the starter Kit already has this folder). Inside those i put my resources i needed for my custom controls. I then opened the java files for those custom controls and looked for where the resources were called. i updated the resource path like this

this is what was there

ScriptResource resources = new ScriptResource();

this is what i changed it to

ScriptResource resources = new ScriptResource();
+ “js/CustomControlLib.js”);

images i did like this
String iconExpr = ResourceProvider.RESOURCE_PATH + “/img/”
+ “#{javascript:compositeData.picklistButtonImg}”;

ResourceProvider is a class in the starter library that gives you your path to the the library and your files inside it. So all img links and hrefs need to updated to point to this location.

Since i did not start with the starter library, i didnt have the extension points in my plugin.xml to allow resources to be served. I got a error stating that it could not load an unregistered resource. Declan Lynch helped me figure out how to get those in there. Nathan T. Freeman helped me get my library working from a blank slate and installed. So unless you are well versed in eclipse and OSGI plugins use the starter library and take out the classes you dont want or need, then refactor it to whatever name you want.


2 Responses to Fun creating my own osgi library and adding my own custom controls to it

  1. Hi Mark,

    In the Resources class of the starter kit, there are methods (addEncodeResource and addEncodeResources) for adding the resources at runtime so you don’t have to define all the different properties.

    Here’s an example of adding a style sheet from XBlog:


    and then adding that resource from the renderer at lines 55 thru 57:


    In that repository are also several examples of custom components with renderers.

    • Mark says:

      Thanks Keith, I just changed the ones above because they were inside a very complex custom control that I copied from another NSF using Tim’s method in his video. But I will take a look for sure on how to do this better, thanks for the tips and code resources!!!

      The biggest lesson I learned from this is USE the starter kit!

Leave a Reply

Your email address will not be published. Required fields are marked *