Chapter 2: Project Structure"

From Documentation
Line 1: Line 1:
 
 
= Source Code =  
 
= Source Code =  
  
Line 27: Line 26:
 
= Project Structure=
 
= Project Structure=
  
The image below shows the project structure of the example application.
+
The 2 images below show the example project structure of the example application.
 +
 
 +
 
 +
<div  style="width:400px;margin-left:auto;margin-right:auto;display:inline">
 +
[[File:Tutorial-ch2-project-structure-upper.png ]]
 +
[[File:Tutorial-ch2-project-structure-bottom.png ]]
 +
</div>
 +
 
 +
We name the source code packages according to each chapter and each package contains those classes used in the example of that chapter. Some common classes are separated to an independent package as they are used in multiple chapters. The classes under <tt>org.zkoss.tutorial.entity.*</tt> are entity class. We also define some business interfaces under <tt>org.zkoss.tutorial.service.*</tt> and different chapters have different implementations.
 +
 
 +
 
 +
For those ZUL pages, we put them in an independent folder for each chapter under <tt>src/main/webapp/</tt>.  You will find the folder for each chapter contains a <tt>readme.txt</tt>, a brief description file which describes the goals of each chapter's example.
 +
 
 +
 
 +
Under "WEB-INF" folder, '''web.xml''' contains some configuration to run ZK. The "zk.xml" is optional configuration descriptor of ZK. Provide this file if you need to configure ZK different from the default behavior.
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
 +
 
  
  
  
[[File:Tutorial-ch2-project-structure.png | 180px | left]]
 
  
We name the source code packages according to each chapter and each package contains those classes used in the example of that chapter. Some common classes are separated to an independent package as they are used in multiple chapters. The classes under <tt>org.zkoss.tutorial.entity.*</tt> are entity class. We also define some business interfaces under <tt>org.zkoss.tutorial.service.*</tt> and different chapters have different implementations.
 
  
  
Line 45: Line 70:
  
  
For those ZUL pages, we put them in an independent folder for each chapter under <tt>src/main/webapp/</tt>.  You will find the folder for each chapter contains a <tt>readme.txt</tt>, a brief description file which describes the goals of each chapter's example.
 
  
  
Line 52: Line 76:
  
  
Under "WEB-INF" folder, '''web.xml''' contains some configuration to run ZK. The "zk.xml" is optional configuration descriptor of ZK. Provide this file if you need to configure ZK different from the default behavior.
 
  
 
= References =  
 
= References =  
  
 
<references/>
 
<references/>

Revision as of 08:49, 9 January 2013

Source Code

All source codes used in this tutorial are available on [github]. Because our example application has 3 different configurations, our source code is divided into 3 branches: master, chapter9, and chapter10.

The master branch contains the examples from chapter 3 to chapter 8. The chapter9 branch has examples integrated with Spring and the chapter10 branch contains examples which integrate with Spring and use JPA to persist data into a database.


You can click the "ZIP" icon to download the current selected branch as a zip file.

Run Example Application

After you download the source code, you will find it is a Maven[1] project with jetty plugin configured. Therefore, if you have Maven, you can run the example application with a simple command[2]. Navigate to the root folder of your downloaded source code, say it's "tutorial" and type the command:

mvn jetty:run


Then visit the URL http://localhost:8080, and you should see the screen below.

Project Structure

The 2 images below show the example project structure of the example application.


We name the source code packages according to each chapter and each package contains those classes used in the example of that chapter. Some common classes are separated to an independent package as they are used in multiple chapters. The classes under org.zkoss.tutorial.entity.* are entity class. We also define some business interfaces under org.zkoss.tutorial.service.* and different chapters have different implementations.


For those ZUL pages, we put them in an independent folder for each chapter under src/main/webapp/. You will find the folder for each chapter contains a readme.txt, a brief description file which describes the goals of each chapter's example.


Under "WEB-INF" folder, web.xml contains some configuration to run ZK. The "zk.xml" is optional configuration descriptor of ZK. Provide this file if you need to configure ZK different from the default behavior.



















References