PDA

View Full Version : Javascript Library



spmva
05-24-2006, 06:04 AM
I hope that I'm posting this in the correct forum.

I was toying with the JavascriptRule and noticed that the component-definition allows for the specification of a "library". The documentation in Pentaho_Creating_Solutions states that the library file must exist in the solution. I placed my "xxyy.js" script in the solution in a directory called "js-library" and added the following tag to the component-definition:


js-library/xxyy.js

When I try to run my simple script I get the following error:


Error: JSRULE.ERROR_0004 - Javascript library not found - js-library/xxyy.js (org.pentaho.plugin.javascript.JavascriptRule)

I then moved that "xxyy.js" file to the root of the solution and modified the library tag to:


xxyy.js

I received a similar error.

Any ideas on what my problem is?

Thanks,

Steve

jdixon
05-24-2006, 07:01 AM
Hi Steve,

I tried your exact scenario and it worked for me.

I create a JS file in


/test/pentaho-demo/pentaho-solutions/js-library/xxyy.js

and referenced it in my action sequence as


<library>js-library/xxyy.js</library>

What version of Pentaho are you running?

James

Post edited by: jdixon, at: 05/24/2006 11:08

spmva
05-24-2006, 07:31 AM
i'm using 1.1.5.262.

i was just able to get it working. i think the terminology messed me up. when the documentation stated that the file must exist in the solution, i though that meant:


pentaho-demo/pentaho-solutions/my-solution

it actually means:


pentaho-demo/pentaho-solutions

now i got it...thanks for the help.

steve

spmva
07-05-2006, 07:48 AM
After upgrading to 1.1.7, actions that used my Javascript libraries started to fail.

I don't know if it is noted anywhere else besides the code, but as of 1.1.7, the <library> tag of the Javascript component is no longer available. Javascript libraries must be specified as <resources> on the action.

The code seems to add any resources that are of the "text/javascript" mime type as libraries to all Javascript components:


while (iter.hasNext()) {
String name = iter.next().toString();
IActionResource libraryResource = getResource(name);
if ( "text/javascript".equalsIgnoreCase( libraryResource.getMimeType() ) ) { //$NON-NLS-1$
if (!PentahoSystem.getSolutionRepository(getSession()).resourceExists(libraryResource.getAddress())) {
error(Messages.getErrorString("JSRULE.ERROR_0004_LIBRARY_NOT_FOUND", name)); //$NON-NLS-1$
return false;
}
if (PentahoSystem.getSolutionRepository(getSession()).resourceSize(libraryResource.getAddress()) > Integer.MAX_VALUE) {
error(Messages.getErrorString("JSRULE.ERROR_0005_LIBRARY_TOO_LARGE", name, Integer.toBinaryString(Integer.MAX_VALUE))); //$NON-NLS-1$
return false;
}
libraryResources.add(libraryResource);
}
}

Anyway, after some adjustments to my actions, I've got everything working properly now.

Steve

dmoran
07-05-2006, 08:16 AM
Steve,

Sorry about that, we added an <action-resources> node to the <action-definition> so it would work like the inputs and so resources could take advantage of the name mapping.

In order to help stay backward compatable if there is no action-resources node, we assume all resources. Any way, if you only want specific javascript files available to your action-definition you can add an action-resources node.


Doug