Put SSJS directly on the server instead of the database - xpages

Has somebody found a way to put a SSJS library directly on the server?
I tried to link with something like:
<xp:script clientSide="false"
src="http://something/mylib.jss">
</xp:script>
It works fine with CSJS and css but a SSJS library brings me an error allthough the path is correct.
Anybody found a solution for this?

Yes. You create an OSGi plug-in than contains your SsJS. Check Nathan Freeman's XSP toolkit on OpenNTF has a sample.
You are then deep in Java land and might decide to just stay there

Related

XPAGES AND ONEUI REFERENCE

I would like to know if you can import the interface used for XPages (oneui) inside the application without the need to have to referencing the server or extend it.
Thank you
Since 8.5.3 OneUI has been delivered via an OSGi plugin on the server. Most modern XPages applications are being built using bootstrap look and feel instead, which is again in the OSGi plugin for XPages Extension Library on OpenNTF. IBM have also moved away from OneUI for IBM Verse and for responsive XPages have adopted bootstrap. I'm not aware of anyone who has tried to pull those into an NSF, and I would not advise it. You may hit Java security exceptions with some of the code, mapping between resources may not work, and there are an immense number of Java classes and other resources. And if you do hit any issues, you are unlikely to find much help to solve them.

how do you add java code in WEEBLY

I want to add my custom java code in my WEEBLY website, using embeded code. How do I do this?
I don't think you can add custom java code. From their tutorial, it looks like you can only embed HTML.

xpages: convert from org.openntf.xsp.bootstrap.library to extension library?

Is there an easy way to modify an application that has been built using bootstrap4xpages so it now uses that same code that has become part of the extension Library? This would allow the application to get the updates as I guess the bootstrap4xpages plugin won'T be updated anymore.
Thanks :)
If the application uses the Select2 control, you'll still need both in the xsp.properties. That's because there are licensing issues that prevented the Select2 control being included in Extension Library plugin.
Otherwise, as Per says, you can just remove the org.openntf.xsp.bootstrap.library reference from the xsp.properties.

Xpages Starter Kit Server.jss

I have a lot of SSJS codes on many NSF, most of the NSF use the same functions code.
So I tried to make a Library with all the common functions, I'm trying to use the Xpages Starter Kit, because it claims to have SSJS Library Provider and implicit global SSJS.
There theres a Server.jss file that says "//your SSJS library code goes here".
I put some simple code there just to test it, but I couldn't figure out how it works.
print("Hello World");
function hello(){
print("hello");
}
How it works?
I made and install the update site, put the <openntf:canvas/> on a xpage. The canvas tag is created, but nothing seems to happen with the SSJS. Nothing on server console, and if a try to call hello function an error is raised.
How can I access SSJS functions on the library?
The library id - org.openntf.xsp.starter - is defined various places in the Starter Kit. It's also there with "/" instead of "." for some contexts.
Also, double-check the library has been enabled in Xsp Properties for your application.
It's also worth looking at the Domino Debug Plugin on OpenNTF to debug your code directly in Eclipse. Also check the Help > Support > Trace and Help > Support > Log in Domino Designer for any errors for your class.

portlet-liferay.xml: How to use portal-javascript-header correctly

I copied jquery.js to WebContent/js/jquery/jquery.js. Now I want to use that file in certain portlets. To do this I created a liferay-portlet.xml that looks like this:
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC
"-//Liferay//DTD Portlet Application 6.0.0//EN"
"http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">
<liferay-portlet-app>
<portlet>
<portlet-name>MyPortletName</portlet-name>
<header-portal-javascript>/js/jquery/jquery.js</header-portal-javascript>
</portlet>
</liferay-portlet-app>
If I access the portlet Liferay generates this line:
<script src="/js/jquery/jquery.js?browserId=firefox&minifierType=js&languageId=en_US&b=6100&t=1326630657000" type="text/javascript"></script>
That leads to a WARN [404_jsp:?] /js/jquery/jquery.js in the logging console.
Is it really correct that the URL looks like this? If I had two war-files, both containing a js-file with the same path, how would Liferay distinguish those two?
What do I need to do to get my setup working?
Using Liferay Portal Community Edition 6.1.0 CE (Paton / Build 6100 / December 15, 2011)
Use
<header-portlet-javascript>/js/jquery/jquery.js</header-portlet-javascript>
isntead of
<header-portal-javascript>/js/jquery/jquery.js</header-portal-javascript>
if you put js-files in to portlet
Because regarding comments in DTD, header-portal-javascript sets the path of JavaScript relative to the portal's context path. And header-portlet-javascript sets the path of JavaScript relative to the portlet's context path.
The location for jQuery looks incorrect.
If you're bundling this with your own plugin named foobar-portlet the correct path would be (provided that you use the same liferay-portlet.xml):
foobar-portlet/docroot/js/jquery/jquery.js
Two things:
jQuery is bundled with Liferay 5, check the version of Liferay and which jQuery version it has bundled and see if this meets your needs. However I believe it's not in Liferay 6 or 6.1, but I could be wrong about that.
And:
If you want to have a JavaScript library available to all of your portlets you're better off adding it to the theme(s) that you use rather than the portlets. This way it will be globally accessible. The downside is that if you're distributing your portlet then you should make people aware of this dependency.
Otherwise if you just want it available to a small group of your portlets, then follow what RP said.
Here's some good reference on using jQuery with Liferay 6.

Resources