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-12-01 13:29:25 +0800

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

updated 2009-12-01 13:32:07 +0800

Hi Erick,

1. Table names cannot be changed because the backend project is historical growth and used in other tests for other view technologies.
2. Because i used Spring configured in xml, so i must do the same in Hibernate.
3. The commenst are in classes and methods. The general overvies comes next times.
4. With a pom, i must change the project structure. Secondly maven is not easy to configure with eclipse and for beginners.
5. I will not use JPA because the great hibernate features are not supported by the actual JPA and the next JPA too.

Thanks
Stephan

PS: next release comes in the next days

link publish delete flag offensive edit

answered 2009-12-01 20:47:41 +0800

wanlim0817 gravatar image wanlim0817
45

Hi,Stephan

these days I have deeply dig about you project,it's wonderful and excellent,you are doing a great job.And really look forward you new release,when it will publish?


Thanks
Mike

link publish delete flag offensive edit

answered 2009-12-10 08:34:20 +0800

wanlim0817 gravatar image wanlim0817
45

updated 2009-12-10 08:40:59 +0800

Hi,Stephan

Today I found a bug in you ZK sample application.

In your language domain object in you de.forsthaus.backend.model package, your override th hasCode method,
there is a problem,your lanId is a string type,and in you override hascode method,you parse it to a Integer.but
you create two language objects which value are "de_DE" adn "en_EN",so there is a problem.
public int hashCode() {
return Integer.valueOf(getLanId()).hashCode();
}

Hope you can fix it in your next edition.

thanks

Mike

link publish delete flag offensive edit

answered 2009-12-10 10:46:23 +0800

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

updated 2009-12-10 14:45:47 +0800

Thanks Mike,

you are right. This is never used at time, because there are no table for saving it and the language is localized.
Default english and second german.
I will correct this.

Stephan

link publish delete flag offensive edit

answered 2009-12-11 03:15:13 +0800

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

Hi Mr Tornado, How is it going?

I have a little cuestion about ZK and I thougth maybe you can help me...
I would like to refresh the screen automatically from time to time, I mean, every 3 or 5 minutes, I want the browser reloads the data that I show in a grid component, you know.
I dont know if it is possible or If you got something like that in your super application.

thanks in advance.

link publish delete flag offensive edit

answered 2009-12-11 12:30:51 +0800

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

updated 2009-12-11 14:18:31 +0800

Hi scerro,

there are a few ways you'll found by searching the froum and zkoss site for serverPush.

- In the sample app you will find a serverPush example with comet in the adminstration area. The login log modul.
- an other way is to start a timer in the client that calls every i.e. 3-5 minutes a DAO routine from you backend that refreshes the data.

best
Stephan

PS: mail me if you hear from your customers.

link publish delete flag offensive edit

answered 2009-12-21 12:07:16 +0800

tariq gravatar image tariq
15 1

Hi Terry,

I looked into your solution which very nice! Great Job!

I am new at ZKOSS I'm trying to work ZK with SpringFramework authentication against LDAP / Active Directory. But I'm not having much luck... See my post http://zkoss.org/forum/listComment/10606

I looked into your solution but I couldnt figure out HowTo make ur solution work with LDAP / Active Directory. Do You have some ideas for me ... I would be very thankfull.... Here is a link from SpringFrameWork Forum http://forum.springsource.org/showthread.php?t=81320

Regards
Tariq

link publish delete flag offensive edit

answered 2009-12-22 04:47:24 +0800

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

Hi Tariq,

I'm having no exxperience with LDAP.

I take a short look of the spring-security api and doc. Seems it goes the same way like our sample.
We use the DAO authentication by coded out the Interfaces UserDetalService. So you must implemented the
needed Interfaces for the LDAP authentication.

Like the doc said and Gregor in the forum: matching real unique LDAP "Distinguished name" DN .
Means there must be a real server for testing.

By the way if found this in your code:

bind_DN=cn={0},ou=xxx,dc=yyy
12:20:29.351 [18100302@qtp-22862399-6] DEBUG o.s.s.p.l.a.BindAuthenticator - Failed to bind as cn=xxx,ou=yyy,dc=zzz

hope it helps a little bit.

best
Stephan

link publish delete flag offensive edit

answered 2010-01-11 05:42:37 +0800

mordor gravatar image mordor
42

updated 2010-01-11 05:43:41 +0800

Great job, but can I ask you about sources? On google code page I can find only old version sources and on source forge page I couldn't find anything :( or maybe you can show me here how you implement tabbing in main window.

link publish delete flag offensive edit

answered 2010-01-11 09:28:16 +0800

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

updated 2010-01-11 16:53:12 +0800

Hi morder,

Yes the sources are not a secret, they are opend. We are hurry up on the documentation of the new Zksample2 app.
Hope in the next days we are finished and checked in as a new project on sourceforge.net.

best
Stephan

attached the routine for the tabs:

                           ....
			<center id="center" border="none" margins="0,0,0,0"
				flex="true">
				<div id="divCenter">
					<tabbox id="tabBoxIndexCenter" width="100%">
						<tabs id="tabsIndexCenter"></tabs>
						<tabpanels id="tabpanelsBoxIndexCenter">
						</tabpanels>
					</tabbox>
				</div>
			</center>´
                          ...

private void showPage(String zulFilePathName, String tabName) throws InterruptedException {

		try {
			// TODO get the parameter for working with tabs from the application
			// params
			int workWithTabs = 1;

			if (workWithTabs == 1) {

				/* get an instance of the borderlayout defined in the zul-file */
				Borderlayout bl = (Borderlayout) Path.getComponent("/outerIndexWindow/borderlayoutMain");
				/* get an instance of the searched CENTER layout area */
				Center center = bl.getCenter();
				// get the tabs component
				Tabs tabs = (Tabs) center.getFellow("divCenter").getFellow("tabBoxIndexCenter").getFellow("tabsIndexCenter");

				/**
				 * Check if the tab is already opened than select them and<br>
				 * go out of here. If not than create them.<br>
				 */
				List<?> list = tabs.getChildren();
				for (Object object : list) {
					if (object instanceof Tab) {
						if (((Tab) object).getId().trim().equals("tab_" + tabName.trim())) {
							((Tab) object).setSelected(true);
							return;
						}
					}
				}

				Tab tab = new Tab();
				tab.setId("tab_" + tabName.trim());
				tab.setLabel(tabName.trim());
				tab.setClosable(true);

				tab.setParent(tabs);

				Tabpanels tabpanels = (Tabpanels) center.getFellow("divCenter").getFellow("tabBoxIndexCenter").getFellow("tabsIndexCenter")
						.getFellow("tabpanelsBoxIndexCenter");
				Tabpanel tabpanel = new Tabpanel();
				tabpanel.setHeight("100%");
				tabpanel.setStyle("padding: 0px;");
				tabpanel.setParent(tabpanels);

				/*
				 * create the page and put it in the tabs area
				 */
				Executions.createComponents(zulFilePathName, tabpanel, null);
				tab.setSelected(true);

			} else {
				/* get an instance of the borderlayout defined in the zul-file */
				Borderlayout bl = (Borderlayout) Path.getComponent("/outerIndexWindow/borderlayoutMain");
				/* get an instance of the searched CENTER layout area */
				Center center = bl.getCenter();
				/* clear the center child comps */
				center.getChildren().clear();
				/*
				 * create the page and put it in the center layout area
				 */
				Executions.createComponents(zulFilePathName, center, null);
			}

			if (logger.isDebugEnabled()) {
				logger.debug("--> calling zul-file: " + zulFilePathName);
			}
		} catch (Exception e) {
			Messagebox.show(e.toString());
		}
	}

call it with: showPage("/WEB-INF/pages/guestbook/guestBookList.zul", "Guestbook");

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