To make pre-configured resources (templates, stylesheets, etc.)
available to web applications, Click automatically deploys configured
classpath resources to the /click
directory at startup
(if not already present).
You can modify these support files and Click will not overwrite them. These files include:
click/error.htm - the Page Error Handling template
click/control.css - the Controls cascading stylesheet
click/control.js - the Controls JavaScript library
click/not-found.htm - the Page Not Found template
For example to customize the control styles you can place a customized
copy (or even a brand new version) of control.css
under
the /click
folder in your web project:
/webapp/click/control.css
When Click starts up it will not
override your copy of control.css
with its own default
version.
Different controls might deploy different stylesheet, javascript or image
files, however the above principle still applies. By placing a customized copy
of the stylesheet, javascript or image under the /click
folder,
you will override the default resource.
Be aware that some of the more complex controls (checklist, colorpicker,
tree), deploys resources to subfolders under /click
, for
example /click/checklist/*
.
A control's Javadoc will normally indicate what resources are deployed for that control.
It is generally easier to work with unpacked WARs and most servlet containers do just that. However some contains such as WebLogic (at least version 10) does not. To enable WebLogic to unpack the WAR go to the Admin Console > server node > Web Applications tab and check the Archived Real Path Enabled parameter.
If Click cannot deploy resources because of restricted file system permissions, warning messages will be logged.
If your application server does not unpack the WAR/EAR or has restricted permissions, you will need to package up these auto deployed files in your web applications WAR file. To do this you should run you application on a development machine without these restrictions and then package up the deployed files into the WAR/EAR before deployment.
Click supports two ways of deploying pre-configured resources (templates, stylesheets, JavaScript etc.) from a Jar to a web applications.
Through a Control's onDeploy() event handler. See the Controls section above.
By packaging the resources (stylesheets, JavaScript, Images etc.) into a special folder called 'META-INF/web'.
As option #1 was already discussed above in section Controls, lets look at option #2.
When Click starts up, it scans each Jar in the classpath for specially marked entries starting with 'META-INF/web/'. (Please note that even though Click will scan the entire classpath it is strongly recommended to host your Jar files inside your WAR lib folder e.g. WEB-INF/lib. Sharing Jars on the classpath can lead to class loading issues.)
Click will then copy all files found under 'META-INF/web/' to the web application folder.
For example, given a Jar file with the following entries:
META-INF/web/mycorp/edit_customer.js
META-INF/web/mycorp/edit_customer.css
mycorp/pages/EditCustomerPage.class
Click will copy the files '/mycorp/edit_customer.js' and '/mycorp/edit_customer.css' to the web application folder.
Thus if the web application is called 'webapp', the files will be deployed as 'webapp/mycorp/edit_customer.js' and 'webapp/mycorp/edit_customer.css'.
Option #2 is especially useful when you need to deploy a large number of resources from a Jar. Note, only Jars placed under the 'WEB-INF/lib' folder will be deployed.