0

ZK Sample App with Spring / Spring-Security / Hibernate / Jasper / Generic-Hibernate-DAO

asked 2009-08-11 22:27:43 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-10-12 23:59:47 +0800

Hi all,

Now it's time to give back all what i have learned for the ZKoss framework. Many thanks for the great
zk-team and the community and much more thanks to 'hkn' who helps me with my first steps on zkoss
and gaves me a red line in the right direction with the java-controllers and the famous baseCtrl class for
doing the whole binding/forwarding stuff.

Why today?

The last few days i'm reading about the SpringSource dm Server which is a OSGi appServer build around the tomcat.
My intention for zkoss is to migrate a very big business application that i have written ago 15 years with
Borland Delphi on win32 up to the web for a Saas (Software as a Service). So for me it's not important
to have much client/browser features. The app must run stable and scalable. It's not a fun application it's for
daily working and the customers wants as stable as a tank .
Today the power grows on serverside. So ZKoss is great for this. (So in my business oriented case I'm not
understanding the zk5 intention with the client side orientation ??)

Today i have read that SpringSource is buyed from VMWare for $ 430 Mill. !!!!
Hmmmmmmmmmm, opposing meanings in the papers/forums what the intention of VMWare is. But a few guys
see that their is a virtualising/clouding infrastructure growing. That's a possibility !
Look at the prices for hardware. ServerPower will always be cheaper.
Think about a modularisized zk application :-)

OK. So back to the basic.


The sample application is checked in on google.

It's the sample application you can see under https://62.75.171.30/test/
usr/pwd = admin/admin
Works with a postgreSQL DB 8.2.6.



And yes, it's blocked up at 200.000 records of customers. I have only a small vServer
to deploy the application. From time to time i will delete some customer records that you
can press the all side loved single-comitted-insert 1.000/10.000 records button newly :-)

Hope i can show the paging with about 4-5 Mio. records on a 16 core 64 GB machine some days :-)



- Seperated as frontend and backend project. All as Eclipse 3.4 projects.
- The backend is older and used for other frontend/technic framework testings too.
So sorry for a few not used methods, but it can be interested for hibernate beginners.
- Most comments are in the code. Please have a look on the folder structure and see the red line.
- More comments and a overview follow under the folder /docs in the ...gui project next days/weeks.

frontend project
backend project

- Implemented with following frameworks:
- spring
- spring-security (I'm extending the spring rights management for a so called 'group' and 'group-rights' that holds seperated logical units of rights. All are loaded from database tables. So we and our customers can customizing the access without new tomcat starting while it's not loaded from a configuration file :-) )
- hibernate as ORM
- JasperReports for reporting
- Generic-Hibernate-DAO for creating hql queries from a search-object. Used for all listboxes.
- H2 DB v1.1.15 for a easier demo mode, which is started and filled with demo-data by starting the application on tomcat.

- Localisation for english and german
- All logged in users became their own singleton UserSpace and their own rights arraylist.


Have fun

regards
Stephan

my Blog
PS I: Help to prevent the global warming by writing cool software.
PS II: Hope that other guys are willing to extend this sample

ToDo List:
- check for securing methods with annotations. First try is failed. @Secured("myZkossMethod")
- help for find out what must in the Session Object for a clustering http SessionFailover
- Drag'n Drop sample
- charting
- ...

delete flag offensive retag edit

44 Replies

Sort by » oldest newest

answered 2009-11-03 03:13:49 +0800

scerro gravatar image scerro
273 3 9
www.desarrolloagil.es

Hi TerryTornado,

I am testing your project. Let me see you. It is great and there are a lot of hours working in that.
I want to deploy the project in my tomcat, but I dont know too well how can I do it, because I have downloaded the two projects (front and back end) and I imagine that I have to make a war of the front-end project but I dont know If I have to make a Jar file with the backend project and then import it into the WEB-INF/lib folder...

could you help me?

thanks in advance.

link publish delete flag offensive edit

answered 2009-11-03 03:21:33 +0800

obiwan gravatar image obiwan
57 2
http://www.payroll.it

Hi scerro,
i do the same work last week, it's very easy, you need only to
import the two project into eclipse than right click on the zk_sample_gui project and do export => war file.
Eclipse will do the rest for you.
Bye

link publish delete flag offensive edit

answered 2009-11-03 04:48:36 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-11-03 04:52:11 +0800

Yes it's like obiwan says.

The frontend project have a dependeny to the backend project.
You can see the settings for this in eclipse.

For a normal swing application you can add needed sub-project to your main project by adding these in the project properties
Category 'Build Path'

In a web project you would bundle all sub-projects(jars) in the same war-file for exporting. So you must done these by adding
these sub-jars as EE module dependencies.

-> (right click on zk_sample_gui --> properties -->JAVA EE Module Dependency

best
Stephan

PS I: next days they come a new version with few bugfixes and a lot of corrections. So you must try a svn synchronize weekly.

link publish delete flag offensive edit

answered 2009-11-03 06:16:33 +0800

rifi01 gravatar image rifi01
21

Hi, I want a simple code on how reccupérer data from a database with JDBC and all this for how it works the archetecture 3 tiere with VIEW, CONTROLLER SERVICE in ZK FRAMEWORK.thanks

link publish delete flag offensive edit

answered 2009-11-11 08:03:12 +0800

scerro gravatar image scerro
273 3 9
www.desarrolloagil.es

Hi there,

I am insterested in knowing how did you change the style in the window components. I have been taking a look to your source code but I dont understand How you change the header default style window. I want to change the header's blue color (it came by default) but I can not change it completely. I am using firebug to see the generated html code and I think the window is formed with some images. How can I change them?

thanks terry. Excellent work.

link publish delete flag offensive edit

answered 2009-11-11 08:59:49 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-11-11 09:16:30 +0800

Hi scerro,

There is a jar in the lib folder called Plomo.jar . This is the grey theme. It was created from a forum user here.
But there are errors in it like double separators.
I have 3 times played with the zkThemer but all times i have not get it to run to see an other theme :-(

Next release (next week) is a full refactoring with:
1. Spring-managed frontend . (At time only the backend is spring-managed)
2. Method securing with Spring Annotations like (@Secured({"myMethodRight"}) or @Secured({"Administrator"}) .
3. Some bugfixes. missing features like ListFooters
4. A working simulation of a one-time-password generator (Thanks to Björn). In our UseCase the generated 6-digits token from an
additionally desktop application will be attached to the password and evaluating at server side by the users authentication procedure
with its saved client token. This is done in a time synchronisation with allowed 2 minutes difference between server time and tokenizer time(client app).
Therefore is on the login window a button for getting the server time.

best
Stephan

link publish delete flag offensive edit

answered 2009-11-11 09:29:54 +0800

scerro gravatar image scerro
273 3 9
www.desarrolloagil.es

Thank you so much Terry,

anyway, could you tell me your email address or could you send me a blank mail to my account ([email protected]) I would like to tell you about several things and It is not the better place. )

thanks!

Sergio

link publish delete flag offensive edit

answered 2009-11-15 11:42:47 +0800

erickmelo gravatar image erickmelo
87 2

Hi TerryTornado,

At first I would like to say You did a Good Job!! This kind of sample application was needed to promote ZK Framework... A complete example that shows the life cycle to build a ZK App... Many people are evaluating ZK as a Enterprise Platform and a complex Sample App is very interesting for this evaluation.

I have just a simple suggestion to improve the example: use Maven to build the project..

link publish delete flag offensive edit

answered 2009-11-16 08:21:40 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-11-16 08:22:34 +0800

@scerro : sge(at)forsthaus(dot)de

@erickmelo: The sample app you can see in the net is build by maven2. Because my normal deploy time about such a war file is about 45 min. per upload stream.
So a friend have spend much time to get it to run under maven2. Now the build is direct on the web-server. Maven checks out the sources from our SVN and download the
needed jars from the web. Now the build/deploy time is about 40 sec. :-)
We do it not 100% maven like because i have problems with the zk versions that
are founded in the maven repositories. So i will all times test it with the newest zk version we said maven that he should download the zk jars from
the lib-folder of the project.
In the next days comes a full refactoring of the projects/sources.

best
Stephan

PS: For all who will use maven2 with the newest zk.jars by loading it from the projects lib-folder. Here is our pom.xml as sample:
pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>de.forsthaus</groupId>
	<artifactId>zkoss</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>${project.artifactId}->${project.version}</name>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.5</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-core</artifactId>
			<version>2.0.5.RELEASE</version>
			<exclusions>
				<exclusion>
					<artifactId>spring-support</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-core</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-aop</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-beans</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-context</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-remoting</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-jdbc</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-web</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-mock</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.12</version>
		</dependency>
		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<version>1.1</version>
			<exclusions>
				<exclusion>
					<artifactId>servlet-api</artifactId>
					<groupId>javax.servlet</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>de.daibutsu</groupId>
			<artifactId>spring-hibernate-backend</artifactId>
			<version>1.0-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>de.daibutsu</groupId>
			<artifactId>KeyGenZkoss</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-core-tiger</artifactId>
			<version>2.0.5.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>commons-fileupload</groupId>
			<artifactId>commons-fileupload</artifactId>
			<version>1.2.1</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zkforge.el</groupId>
			<artifactId>zcommons-el</artifactId>
			<version>1.0.2</version>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zk</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zk.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkex</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zkex.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkmax</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zkmax.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkplus</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zkplus.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zul</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zul.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.common</groupId>
			<artifactId>zweb</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zweb.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zhtml</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zhtml.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkmax</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zkmax.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zkspring</artifactId>
			<version>1.1.0</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zkspring.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zml</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zml.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.zkoss.zk</groupId>
			<artifactId>zcommon</artifactId>
			<version>3.6.3</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}zcommon.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.supercsv</groupId>
			<artifactId>supercsv</artifactId>
			<version>1.5.2</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}SuperCSV-with_src-1.52.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>spiffy</groupId>
			<artifactId>spiffy</artifactId>
			<version>0.0.5</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}spiffy-with_source-all-0.05.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>web.Th1</groupId>
			<artifactId>plomo</artifactId>
			<version>1.0.0</version>
			<scope>system</scope>
			<systemPath>${zkosslibs}Plomo.jar</systemPath>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-acl</artifactId>
			<version>2.0.5.RELEASE</version>
			<exclusions>
				<exclusion>
					<artifactId>spring-support</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-core</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-aop</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-beans</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-context</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-remoting</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-jdbc</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-web</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-mock</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-taglibs</artifactId>
			<version>2.0.5.RELEASE</version>
			<exclusions>
				<exclusion>
					<artifactId>spring-support</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-core</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-aop</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-beans</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-context</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-remoting</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-jdbc</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-web</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
				<exclusion>
					<artifactId>spring-mock</artifactId>
					<groupId>org.springframework</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.webflow</groupId>
			<artifactId>spring-webflow</artifactId>
			<version>2.0.8.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.beanshell</groupId>
			<artifactId>bsh</artifactId>
			<version>2.0b4</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>
	<parent>
		<artifactId>zkoss-Webapp</artifactId>
		<groupId>de.forsthaus</groupId>
		<version>1.0-SNAPSHOT</version>
	</parent>
	<build>
		<finalName>maven-zkoss</finalName>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.0</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<dependencyManagement>
		<dependencies>
		</dependencies>
	</dependencyManagement>
	<properties>
		<zkosslibs>${basedir}/src/main/webapp/WEB-INF/lib/</zkosslibs>
		<spring.version>2.5.6</spring.version>
	</properties>
</project>

link publish delete flag offensive edit

answered 2009-11-20 10:32:55 +0800

erickmelo gravatar image erickmelo
87 2

Hi Terry,

Thank you for the answer... I would like to give you some suggestions to the refactoring process that you are doing:

- Use the class with names in English (you have some class names in English and other in Germany)
- Use Hibernate Annotation
- Add comments about the libraries used (like trg search)
- Add a pom.xml

And if possible evaluate the possibility to use JPA instead of Hibernate..

You are doing a great job!!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-08-11 22:27:43 +0800

Seen: 22,788 times

Last updated: Dec 06 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More