We have been using WaveMaker and wanted to know how we can go about importing an external javascript file using the platform ?
Importing javascript files on WaveMaker
347 Views Asked by alphadelta10 At
2
There are 2 best solutions below
0

- The external JS file should be imported into a folder in resources
- The file path has to be given in login.html of the Web-App
- The file path should be of the form "/projectname/foldername/filename.js/"
- The functions in the external JS file can be accessed in the login page through its script and the function invoked here is from a sample js file.
0

The following works if using WaveMaker 6. This probably doesn't work with newer versions of WaveMaker.
Instead of having to add it to each project, try editing index.html
in the webapproot
directory and add you external js file:
<!-- Boot Wavemaker -->
<script type="text/javascript" src="config.js"></script>
<script type="text/javascript" src="/<path to javascript file>/sha512.js"></script>
Then, in order to have this work correctly in your development environment, add a context tag to server.xml
just above the projects directory:
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context docBase="c:/<Path To Javascript Filet" path="<path to javascript file matching whats in index.html>" reloadable="true"/>
</Host>
In the above Context
tag, docBase
is the local folder with js and path
should match the path placed in index.html
.
Doing this you can use the javascript file across all projects without having to add it to resources
in the project.