2
votes

I am trying to develop my own Java Custom Control in XPage following the guide on IBM (LINK).

Everything works fine but now I want to do some client side JavaScript things where I want to use the jQuery library. Including the jQuery.js in a XPage is not a great deal but I want to pack my control in a Library so that every developer at our company can use it.

So my question is how can I integrate the JavaScript in the control so the one who uses it doesn't have to implement the JavaScript in Notes Application by hand.

Sure, I could just put it into the render:

writer.startElement("script", null);
writer.writeAttribute("type", "text/javascript", null);
writer.writeText(JQuery-js-content, null);
writer.endElement("script");

But then the server has always to render it when a user opens a XPage which contains the control.

Loading the jQuery from the web or from an Server is no option (Firewall).

What I am searching for would be a solution whenever a developer drags the component from the panel the jQuery gets added to the Notes Application.

UPDATE:

Thanks for the hint's I found "the for me best" solution.I used the ExtLibResources Class from the Extension library com.ibm.xsp.extlib.resources.ExtLibResources to include my Script libraries. With this method they won't get included several times when you use more then one of my controls on the same XPage.

If you don't want to use the Extension Library but you want to use this method to include a CSJS in your custom control you can just build you own Resource Class.

Now my Code to include jQuery looks like this:

ScriptResource jquerymin = new ScriptResource();
jquerymin.setType("text/javascript");
jquerymin.setSrc(JQUERY_PATH);
jquerymin.setClientSide(true);
ExtLibResources.addEncodeResource(context, jquerymin);
2

2 Answers

2
votes

Check out this project on OpenNTF. a jQuery Ext. Library. I suspect this is what you'd need to do.

http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=jQuery%20Extension%20Library

0
votes

Instead of adding the library yourself wouldn't it be possible to add the jquery libraries using CDN?