Monday, October 6, 2008

A complete Click application configuration example

Click applications are configured through the ConfigService interface.

The default ConfigService implementation is XmlConfigService which is configured through the click.xml file.

click.xml is defined by a DTD which some folk find easy to understand and follow. I however, am not one of them.

I enjoy learning from examples (not to mention it allows for easy copying and pasting) so I've put together an example of all the configuration options specified by the DTD:

<!-- A Click Application (click.xml) Example. -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<click-app charset="UTF-8" locale="en">

<!-- A automatically mapped Page package. Note automapping and autobinding is true by default -->
<pages package="" automapping="true" autobinding="true">
<!-- A custom mapped Page -->
<page path="index.htm" classname=""/>

<!-- Another mapped Page with custom headers -->
<page path="login.htm" classname="">
<!-- Specify headers to cache the page for 1 hour, after which it should be reloaded -->
<header name="Pragma" value="no-cache"/>
<header name="Expires" value="1" type="Date"/>


<!-- Another automatically mapped Page package -->
<pages package=""/>

<!-- Setup global headers. The headers shown below is the default used by Click -->
<header name="Pragma" value="no-cache"/>
<header name="Cache-Control"
value="no-store, no-cache, must-revalidate, post-check=0, pre-check=0"/>
<header name="Expires" value="1" type="Date"/>

<!-- Setup alternative Format. Default Format is -->
<format classname="com.mycorp.util.Format"/>

<!-- Mode values include: [production], [profile], [development], [debug], [trace] -->
<mode value="production"/>

<!-- Set Click internal Logger to Log4J instead of the default ConsoleLogService -->
<log-service classname=""/>

<!-- Set the template engine to use Freemarker instead of Velocity -->
<template-service classname=""/>

<!-- Set the properties: sizeMax and fileSizeMax. -->
<!-- Set the total request maximum size to 10mb (10 x 1024 x 1024 = 10485760). The default request upload size is unlimited. -->
<property name="sizeMax" value="10485760"/>

<!-- Set the maximum individual file size to 2mb (2 x 1024 x 1024 = 2097152). The default file upload size is unlimited. -->
<property name="fileSizeMax" value="2097152"/>
<!-- The commented section below shows how to use the classname attribute to specify -->
<!-- a custom implementation. -->
<file-upload-service classname="com.mycorp.util.CustomFileUploadService">
<property name="sizeMax" value="10485760"/>
<property name="fileSizeMax" value="2097152"/>

<!-- List controls which will deploy their resources on application startup -->
<control classname=""/>

<!-- A control-set which refers to a third-party xml file specifying the list of controls to deploy -->
<control-set name="mycorp-third-party-controls.xml"/>

<!-- Example mycorp-third-party-controls.xml file -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<control classname="com.mycorp.control.MyCorpTable"/>
<control classname="com.mycorp.control.MyCorpForm"/>




DunSun said...

Hi there,
I'm new to a Click framework.
I do like Click's minimalist approach.

But please could you give any suggestions how the hell can I run project which I have created via ClickIDE ?

ClickIDE is great. Project creation is easy ... but I need it to run.

I would say that even installation alone is not very straightforward.

Thank you for you help.

Bob Schellink said...


I use Netbeans for my Click development so don't really know ClickIDE. Its author, Naoki Takezoe, does hang around the Click mailing lists though so you might want to post your question there.

Also I don't think ClickIDE actually "runs" your application. ClickIDE depends on Eclipse + WTP and WTP (Web Tools Project) is the plugin which allows you to run web applications on a server such as Tomcat, JBoss or Glassfish. (not sure which servers are supported out-of-the-box by Eclipse JEE)

Once Eclipse JEE is installed you still need to grab a server such as Tomcat.

Then inside Eclipse switch to JEE perspective and open the Server view. Right click inside the Server view window to setup your server.

With the above in place you should be able to use ClickIDE to setup and edit Click files and run the project.

Hope this helps a bit.

kind regards


iulian maxim said...

Hello do you have an tutorial step by step for beginner to click and cayenne?