Reputation: 53
I'm having difficulties finding the proper approach to provide css and csjs resources in my custom xpages Library. I was not able to find any good info on how to package such resources with my osgi plugin.
I took a look at the extlib implementation, but couldn't really make much of what is happening in the ResourceHandler parts (and if those are even related to what I need, actually). So what steps are necessary if one wanted to deploy, say, a dojo dijit within the library?
Upvotes: 2
Views: 123
Reputation: 53
What did it for me:
Create an OSGi Plugin Activator; in the constructor, load a custom ExtLibLoaderExtension
that basically sits on top of the Extlib resource handling. To use that, the resources need to go into a subfolder of "/resources/web/extlib" with a name that is specified by this very ExtLibLoaderExtension
.
The Activator:
public class MyCustomActivator extends Plugin {
public static MyCustomActivator instance;
public MyCustomActivator() {
instance = this;
ExtLibLoaderExtension.getExtensions().add(new MyCustomLoader());
}
}
The ExtLibLoaderExtension:
public class MyCustomLoader extends ExtLibLoaderExtension {
public MyCustomLoader(){
}
@Override
public Bundle getOSGiBundle() {
return MyCustomActivator.instance.getBundle();
}
@Override
public URL getResourceURL(HttpServletRequest request, String name) {
if(name.startsWith("[put subfolder name here]")) {
String path = ExtlibResourceProvider.BUNDLE_RES_PATH_EXTLIB+name;
return ExtLibUtil.getResourceURL(
MyCustomActivator.instance.getBundle(), path);
}
return null;
}
}
Make sure your resources folder is included in the Build section of your plugin.xml
. On the Overview Tab, provide the Activator class in the section General Information on the top left. After all this, you can access your resources from a Webbrowser by using the /xsp/.ibmxspres/.extlib/[put subfolder name here]/ junction once you've deployed the updateSite and restarted the http task.
Upvotes: 1