Apache - Click

thickbugSoftware and s/w Development

Oct 28, 2013 (3 years and 11 months ago)

74 views

{

Apache
-

Click


By,


Anupam Mundale.


Viraj Kulkarni.






JEE Web Application Framework


Method to build Web Applications without MVC and JSP’s.


Java Language support


Uses HTML templates and POJO’s.


Apache Velocity Engine to support HTML
templates


Built on Java servlet API


Open source Project (Apache license 2.0)


Simple, easy to use, good performance and scalability


Competing Frameworks


JSF, Tapestry, WebObjects and Apache Wicket








Introduction



1) Install Click
-
2.3.0 and add required JAR files to the Project and deploy.


2) Click IDE


Click IDE is an eclipse plugin for developing Click Web Applications.


Click IDE Dependency


Eclipse 3.5.x and WTP 3.1.x


Unzip clickide
-
x.x.x.x.zip and put 2 folders (plugins/ and features/) into
your ECLIPSE_HOME
.


3) Click IDE Features


Fast switching between Page classes and
templates


Project
creation
wizard


Click
page creation
wizard


Visual
editor for the Click configuration
file


Velocity
template
editor


Spring
Framework and Apache Cayenne
Integration


Integrated
Click documentation





Click


Project Environment and Click
IDE


Org.apache.click.page



Base Class



-

It contains methods and allow to handle events.



-

You can override in
-
built methods to provide custom



functions.



Control Components


setEventListner

()


-

Example
:




Submit
submitButton

= new Submit("Submit Me", this, "
onClick
");


When
the button is clicked, the event is dispatched to
your custom Page class’s



onClick
()



Apache
Click uses the Apache Velocity
templating

engine



Templates
are matched automatically with the classes that extend

Page

in your
application using some default mapping rules

Click Basics


1) Create Application


Select

New > Other

from the Eclipse
menu.


From

Select a Wizard
, choose

Web / Dynamic Web Project

and
click

Next
.


Type
a name for

Project Name

(for example,

MyFirstClick
).


Select
a

Target Runtime
, such as Apache Tomcat 6.0.


2) Import Click Libraries


Click

File >
Import.


Select

General / File System

from the list and click

Next
.


Browse
to the directory in which you expanded the Apache Click files
and select the
dist

directory.


From
the list of files, select the click
-
{version}.jar and click
-
{version}
-
extras.jar files (see Figure 2).



Make sure the
WebContent
/WEB
-
INF/lib folder is selected in the

Into
folder

Create Web Application using Eclipse and
import Click Libraries

Now that you have the JAR files in your WEB
-
INF directory, modify
the Web application's web.xml file to include
the
ClickServlet
, which
is the single servlet used by Apache Click to dispatch events
.

Create Sample Application


Now create a package into which your page classes will go (for
example,

com.example.myfirstclick.pages
). After you create the package,
create a new file called click.xml in your Web project's WEB
-
INF folder. Put
the name of the package you just created in the click.xml
file.



Now that your project is set up, you are ready to start writing classes that
extend the Apache Click classes
.

Continued….


Create the new class in the package you created by selecting

File > New
> Other

and selecting

Java / Class
. Make sure to
enter

org.apache.click.Page

as the

Superclass








Create
the new HTML page

called
welcome.html






Continued..



You
can
deploy
the application by exporting the files as a Web Archive
(WAR) to the Tomcat
webapps

folder
.



Steps to perform in Eclipse to deploy the app



-

Click
on the project and select

File > Export
.


-

Select

Web / WAR

file and click

Next
.



-
In
the

Destination

field, browse to the Tomcat
webapps





folder
.


-
Make
sure

Overwrite existing files

is selected and



click

Finish
.



Running the Sample Ap
p


Very easy to
learn


Component
and Page Oriented
design


Event
base programming
model


Stateless
(with support for light
-
weight
stateful

components)


Server
-
side
Ajax
support


Exceptional performance


Automatic
form rendering and client/server side
validation


Supports
Velocity, JSP or
FreeMarker

page
rendering


Supports
Java 1.5 and
up


Conclusion


https://click.apache.org
/


http://www.ibm.com/developerworks/opensource/library/w
a
-
apacheclick
/


References

Thank You !!!