2

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);
0

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yup, that look nice, i'll give it a try. Thanks
0

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

1 Comment

Sorry as i said in my question i need to implement the jQuery Lib in the Notes Application. I cant use a CDN because of our Firewall/Proxy and securety policy. Dont have time to develope at the moment (working on different stuff) but i think David Leedy's solution is just what i am searching for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.