I created a set of utils to use inside my BIRT reports.
I put them (my-utils.jar) inside BIRT's lib directory:
BIRT_HOME\plugins\org.eclipse.birt.report.viewer_x.x.x.x\birt\scriptlib
They are working fine, but now I want to create a JS file, put it on the classpath to be able to use it functions.
// my-utils.js
GLOBAL_VARIABLE = {
formatSomething: funnction(value) {
// do my stuff with 'value' and return
}
};
I want to use it directly, without explicity load it inside a Dynamic Text or Script event, like this:
GLOBAL_VARIABLE.formatSomething('bla bla bla')
How can I do this?
You want to create an extension point. In Eclipse, create a new blank plugin-project, then add this extension point:
org.eclipse.birt.core.ScriptFunctionService
Create a folder just under the project root, name it for instance "jslib" and put your js files in this folder.
Edit plugin.xml and add a JSLib tag, so that it should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="my.js.function"
name="My custom JS functions"
point="org.eclipse.birt.core.ScriptFunctionService">
</extension>
<JSLib
location="jslib">
</JSLib>
</plugin>
Export the plugin as a jar and deploy it in Eclipse and/or web applications and your js functions should be available. More informations about custom birt functions here
Note that Dominique's solution is only for the case when the functions are implemented using Java.
The following solution is for the case when the functions are implemented using Javascript:
First, you don't need to add the **.js* files to the classpath.
Instead, you put them into the directory specified for resources and reference them in your report (or in one of the libraries that you are using in your reports). See the following example:
Directory structure:
workspace
\birt # I have this configured as as "Report Project" in the WS
my_report.rptdesign
\res
my-utils.js
In the preferences menu:
Report Design / Resource / Resource folder = <Current Project Folder>/res
(At runtime, you can set the resource folder using the API, I don't know how to configure this for the Web Viewer example)
In my_report.rptdesign, see the properties of the report itself. Inside the "Resources" tab, add my-utils.js to the Javascript Files.
Now you can use the functions of your library in your report.
Related
I'm writing a custom plugin for CKAN and in this plugin I want to overwrite the file https://github.com/ckan/ckan/blob/2.8/ckan/public/base/javascript/modules/image-upload.js from CKAN with a new implementation. Is there a way to do this?
I tried adding the file on the same path in the plugin, but that didn't work.
You can create a fanstatic directory in your extension and move the files there. Then use add_resource function to register that directory as explained here. As an additional example check this extension(register, directory)
What I want to do is add a custom script in package.json file that should run always before start and build scripts.
Things I want to do in my custom script:
Copy the favicon.ico file from /favicons/${process.env.REACT_APP_BRAND}.ico into /public, in order to overwrite the default one
Do a symlink from /src/assets/${process.env.REACT_APP_BRAND} to /src/assets/brand, in order to import images inside code without doing things like dynamic imports (which works but I think it's not their purpose)
I'm a bit lost with the structure of this custom script, and programming languange (its shell, but I'm on MacOS, so, it's better do it in node?)
Thank you.
I'm trying to add an external js file into my Angular2 project by adding the record to my angular-cli.json file.
I've added a file to the [scripts] array as below:
"scripts": ["https://as-identitydemo--c.na50.visual.force.com/resource/1495420277000/salesforce_login_widget_js"],
all the other posts that i've read refer to using this format for something that's either hosted locally, or installed in the node_modules etc..
How can I include an external js library and utilize that in my project?
You should import the library in your index.html in the head tag.
Second you have to make the library visible to your Angular project. That means you need the typings. You can either search https://github.com/DefinitelyTyped
for already existing types or add the types to the typings.d.ts file.
Example:
In your page (outside of the Angular app) you might have a javascript global variable:
var testVar = 'testvalue';
Then in the typings.d.ts you can make this variable globally accessible by adding
declare var testVar:string;
Then you can access this variable in the whole Angular project like that:
console.log(testVar);
The same you can do with functions in external libraries.
Here is a Plunk that shows that (without having a typings file). Hope this helps.
I'm surprised I can't google my answer here... it seems no one else is having the issue.
When you run the meteor service the js, html, etc. is packaged in the .meteor/local/build folder, but it appears to exclude stuff that isn't js or html. I have a folder called "magicsets" and one called "magicimgs" and neither are in the /local/build folder. This is obviously why, when i attempt to use fs to readfile, it fails to find the file "magicsets/M14.json"
I tried putting the magicsets folder into a folder named "private", but that didn't accomplish anything.
How do I make files accessible locally to my server via FS and how do I make files accessible publically to my server via raw urls?
I'm sure I'm missing something very simple, because there are lots of more complicated questions and answers on SO, yet there is no answer for this. Thanks.
Meteor 0.6.5 which was released yesterday has a new feature which helps loads with this.
Make a directory called /private which you can access with the new Assets.getText or Assets.getBinary functions.
The stuff in the /private directory will then be bundled up into a directory called assets in /program/server/assets and it will not be accessible to the web & you wouldn't need to worry about using fs either. You could just use Assets.getText instead
To make a publicly accessible file put it in /public. So if you had a.jpg at /public/a.jpg it would be accessible at http://yourdomain.com/a.jpg
If you want text files to be available to the webserver i.e. the server that defaults to port 3000, create a folder called public in the root of the project/app directory. drop your folder and files there. You would then be able to access them as http://localhost:3000/magicsets/M14.json
update: it looks like can override the bundler, but it does require changing some of the core code there's no .meteorignore file yet. check this SO answer out: https://stackoverflow.com/a/16742853/105282
To serve a directory of files publicly independent of what Meteor is doing, you can use the following approach. I do this, for example, when I need to link an entire (Javascript) git repo into my Meteor app so I can work on a checked out version of the library.
The following works for 0.6.5. It basically servers up a checked out folder of OpenLayers in /lib:
connect = Npm.require('connect')
RoutePolicy.declare('/lib', 'network')
WebApp.connectHandlers
.use(connect.bodyParser())
.use('/lib', connect.static("/home/mao/projects/openlayers/lib"))
For more information, see https://github.com/meteor/meteor/issues/1229.
Is it necessary to give the folder name "resources" when making the reference of a css file and js file in h:outputStylesheet and h:outputScript?
Cause when I am giving the folder name "assets" instead of "resources" these files are not loaded.
This is how I am using these tags:
<h:head>
<h:outputStylesheet name="css/styles.css"/>
<h:outputScript name="js/site.js"/>
</h:head>
And here is my project structure:
In the screenshot you can see the folder name is resources. And then it is working. How can I specify a different name?
The folder name is fixed as per chapters 2.6.1.1 and 2.6.1.2 of the JSF specification.
2.6.1.1 Packaging Resources into the Web Application Root
The default implementation must support packaging resources in the web application root
under the path
resources/<resourceIdentifier>
relative to the web app root. Resources packaged into the web app root must be accessed using the getResource*() methods on ExternalContext.
2.6.1.2 Packaging Resources into the Classpath
For the default implementation, resources packaged in the classpath must reside under the
JAR entry name:
META-INF/resources/<resourceIdentifier>
Resources packaged into the classpath must be accessed using the getResource*() methods of the ClassLoader obtained by calling the getContextClassLoader() method of the current Thread.
It mentions "must" in both cases. It does not mention anything about a possible configuration option to change those paths. This applies to both JSF 2.0 and JSF 2.1.
In the upcoming JSF 2.2, however, it will as per JSF spec issue 996 be possible to change the path by the new javax.faces.WEBAPP_RESOURCES_DIRECTORY context parameter which takes a path relative to the webcontent root as parameter value:
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>WEB-INF/resources</param-value>
</context-param>
This example will move the /resources folder into /WEB-INF, hereby ensuring more security (i.e. it is now not possible anymore to access those resources independently from the FacesServlet).
In your particular case, you'd thus like to use the following setting when having upgraded to JSF 2.2:
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>assets</param-value>
</context-param>
Note that this only covers webapp's own resources as specified in chapter 2.6.1.1, not the JAR resources as specified in chapter 2.6.1.2. The path of JAR resources should still be META-INF/resources as this is controlled by Servlet API specification, not the JSF specification. It's namely under the covers obtained by ServletContext#getResource() method which is outside control of JSF.
It is the way that the Resource Handler has been implemented in JSF 2.0, by default it will look at the following two path:
1) /resources under the root of the web application.
2) /META-INF/resources when packaged in an external JAR on the classpath.
If you want to use a different name, As mentioned by Alexandre, use the <script> and <style> tags or write your own Resource Handler.
More info:
Ryan Lubke's blog entry on JSF 2.0 Resource API
JSF 2.0 spec
You can't specify another directory than resources unless yiu are using
<style></style>
or
OmniFaces CombinedResourceHandler