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="com.mycorp.banking.page" automapping="true" autobinding="true">
<!-- A custom mapped Page -->
<page path="index.htm" classname="com.mycorp.page.Home"/>

<!-- Another mapped Page with custom headers -->
<page path="login.htm" classname="com.mycorp.page.Login">
<!-- 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"/>
</page>

</pages>

<!-- Another automatically mapped Page package -->
<pages package="com.mycorp.common.page"/>

<!-- Setup global headers. The headers shown below is the default used by Click -->
<headers>
<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"/>
</headers>

<!-- Setup alternative Format. Default Format is net.sf.click.util.Format -->
<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="net.sf.click.extras.service.Log4JLogService"/>

<!-- Set the template engine to use Freemarker instead of Velocity -->
<template-service classname="net.sf.click.extras.service.FreemarkerTemplateService"/>

<!-- Set the net.sf.click.service.CommonsFileUploadService properties: sizeMax and fileSizeMax. -->
<file-upload-service>
<!-- 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"/>
</file-upload-service>
<!-- The commented section below shows how to use the classname attribute to specify -->
<!-- a custom net.sf.click.service.FileUploadService implementation. -->
<!--
<file-upload-service classname="com.mycorp.util.CustomFileUploadService">
<property name="sizeMax" value="10485760"/>
<property name="fileSizeMax" value="2097152"/>
</file-upload-service>
-->

<!-- List controls which will deploy their resources on application startup -->
<controls>
<control classname="net.sf.click.examples.control.FilterPanel"/>

<!-- 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"?>
<click-app>
<controls>
<control classname="com.mycorp.control.MyCorpTable"/>
<control classname="com.mycorp.control.MyCorpForm"/>
</controls>
</click-app>
-->

</controls>

</click-app>

3 comments:

Unknown 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...

Hi,

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

bob

iulian maxim said...

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