ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

new Zksample2 app. Spring, -AOP, -Security, Hibernate, Hibernate-Generic-DAO, Jasper

terrytornadoTop Contributor
17 Jan 2010 08:29:28 GMT
17 Jan 2010 08:29:28 GMT

Hi all,

today we have checked in the new Zksample2 application as maven2 projects on sourceforge.net.
You can reach the project homepage under the link http://zksample2.sourceforge.net/ here.

You will find there 3 eclipse maven subprojects and the folder for the documentation.

1. KeyGenZkoss = one-time-password generator
2. spring-hibernate-backend = backend
3. zkoss = frontend
4. zksample2_doc = documentation

The Documentation you can download seperately as a pdf-file from here.

The documentation is a work in progress so be sure to check sometimes for the newest file.

For checkout and evaluate or work with the application please download and read first the documentation.

Mainly changes to the first sample app are:
- change project structure as maven2 projects
- spring managed frontend
- @Secured() for securing methods with own implementation
- login statistic
- several integration options of ipToCountry
- one-time-password sources are opend
- Refactoring all Domain/DAO/Service Classes to english names
- many many code changes
- documentation


We whish all fun with it and hope that it can be usefull for others.

best
Stephan and Björn

wanlim0817
17 Jan 2010 19:27:28 GMT
17 Jan 2010 19:27:28 GMT

Hi,Stephan

congratulations and thanks for your great work.
I'm watting your new version for a long time.Now I'm so exciting to check out your new version of Zksample2.

PS:I'm the first one who give a reply for you, hahahaha:)

kaiak
18 Jan 2010 02:54:37 GMT
18 Jan 2010 02:54:37 GMT

congratulations !

what great work you have done!

GuzZpaWn
19 Jan 2010 13:38:34 GMT
19 Jan 2010 13:38:34 GMT

when a go to http://zksample2.sourceforge.net/ and click on Download files it sends me to
Error 404 We apologize. The page you were looking for cannot be found. You may want to try one of the options listed below.

terrytornadoTop Contributor
19 Jan 2010 16:49:47 GMT
19 Jan 2010 16:49:47 GMT

Hmmmmmmmmm, you are right. Yesterday this is working well.???
Seems the project ID's are lost ???

Go to http://sourceforge.net/projects/zksample2/

The Zksample2 app is hostet here: http://vs171030.vserver.de/test/ here .


Edit: I have get a ticket on SF for correct them.

goldfish
20 Jan 2010 21:48:17 GMT
20 Jan 2010 21:48:17 GMT

Hi terrytornado,

Do you have any plan to update zksample to ZK5 and spring 3? As you know, there many update in this two frameworks.

Thank you.

mordor
21 Jan 2010 03:34:19 GMT
21 Jan 2010 03:34:19 GMT

Hi Terrytornado,

Great job! Looks very nice! Thanks a lot.
It's will be super if you upgrade zksample2 to ZK5, but I think it's should do after ZK5 release! Now I read you code and after that I'll try write you my comments.

terrytornadoTop Contributor
21 Jan 2010 12:13:40 GMT
21 Jan 2010 12:13:40 GMT

@goldfish,

no problem with spring 3.
It's downwards compatible.

If we have time, we will check against zk5 and make new checkin.

best
Stephan

goldfish
21 Jan 2010 21:12:17 GMT
21 Jan 2010 21:12:17 GMT

Hi Terrytornado,

I try to update ZK3 to ZK5, only some layout api need to change. ZK5 moved some layout classes from zkex to zk core. After updated to ZK5, I found some tiny issues--the close button in login dialog did not locate at the right side. The other issue is that renderMessages in Chatter and onSendMsg in ChatWindow can't work because smartUpdate is removed from ComponentCtrl. Other features work fine.

The tiers became more clear in ZKSample2. It gives me much help to study ZK and Spring. Thanks.

mordor
22 Jan 2010 07:07:49 GMT
22 Jan 2010 07:07:49 GMT

Hi Goldfish,

Also I have a problem with even onChange in Combobox component, now it's onSelect.....

Hi Terrytornado,

And what about migration to spring security 3.0.1? There a lot of changes.... It's not so simple like in spring 3 if you didn't you new futures...

terrytornadoTop Contributor
22 Jan 2010 09:33:41 GMT
22 Jan 2010 09:33:41 GMT

@goldfish the earliest time for migrating to zk5 is when zk5 is in the maven- rep.
@mordor, @all

Hmmmmm, we have in mind to make an own security system for our needs because there's much trouble with
synchronizing the zk multithread architecture with spring security. (If you study the code you will find the place
and the method where we catch the @Secured annotation self and not by Spring-sec. if needed )

If you are a big fan on debugging and on solving such problems than you can made 4 changes and help us to find the ground
or a workaround for such a misbehavior. I hope the zk guys can have a look on it if they have time after the zk5 release.

1. de.forsthaus. webui. InitApplicationCtrl.java



- change the BaseController from which is extended.

from: public class InitApplicationCtrl extends WindowBaseCtrl implements Serializable {
to: public class InitApplicationCtrl extends GFCBaseCtrl implements Serializable {

than change ALL getters for the DAOs and Services in this class (at the end of the file)



sample:
from:
public GuestBookService getGuestBookService() {
if (guestBookService == null) {
guestBookService = (GuestBookService) SpringUtil.getBean("guestBookService");
setGuestBookService(guestBookService);
}
return guestBookService;
}

to:
public GuestBookService getGuestBookService() {
return guestBookService;
}

2. zkoss/src/main/resources/applicationContext-zkoss.xml



insert the bean definition:

<!-- Init Pre -Page -->
<bean id="initApplicationCtrl" class="de.forsthaus.webui.InitApplicationCtrl"
parent="basisCtrl" scope="prototype">
<property name="customerService" ref="customerService" />
<property name="brancheService" ref="brancheService" />
<property name="officeService" ref="officeService" />
<property name="ipToCountryService" ref="ipToCountryService" />
<property name="articleService" ref="articleService" />
<property name="orderService" ref="orderService" />
<property name="guestBookService" ref="guestBookService" />
<property name="securityService" ref="securityService" />
<property name="userService" ref="userService" />
<property name="loginLoggingService" ref="loginLoggingService" />
<property name="sysCountryCodeService" ref="sysCountryCodeService" />
</bean>

3. change the controller access in the zul file: zkoss/src/main/webapp/index.zul



from:
<window id="startWindow" border="none" width="100%" height="100%" use="de.forsthaus.webui.InitApplicationCtrl">

to:
<window id="startWindow" border="none" width="100%" height="100%" apply="${initApplicationCtrl}">


With these changes we have following problem:
1. start application
2. get LoginDialog
3. do a login (you can see in the console-log that i.e. you are logged in correct as admin)
4. after login Spring-security is now threw an Error: no authorization. ??????????
5. by refreshing the web page in the browser the app runs normal away.

Have fun and let us know if you find some solution.

best
Stephan

danielgoodwin
26 Jan 2010 05:14:19 GMT
26 Jan 2010 05:14:19 GMT

Hi
Very excellent example.
Apologies for silly question, I'm working through documentation to setup locally to better understand and got to part where I 'import' from sourceforge site
Its asking me for a user/pass but by existing sourceforge account does not work
Should I be able to Import?

org.tigris.subversion.javahl.ClientException: Authorization failed
svn: MKACTIVITY of '/svnroot/zksample2/!svn/act/3a2355d1-70ae-9743-97ac-64d3347988d0': authorization failed: Could not authenticate to server: rejected Basic challenge (https://zksample2.svn.sourceforge.net)

terrytornadoTop Contributor
26 Jan 2010 05:50:23 GMT
26 Jan 2010 05:50:23 GMT

It's not an 'Import'. It's a checkout from svn.
Seems you have copy a false URL. Please correct it:

https://zksample2.svn.sourceforge.net/svnroot/zksample2

than go to trunk and checkout seperate all projects

erickmelo
5 Feb 2010 12:22:52 GMT
5 Feb 2010 12:22:52 GMT

Hi,
I found a bug in the application:

When I try create a new Security Role (with a duplicated role name, as "ROLE_ADMIN") I get an NullPointException error... Probably for bad constraint

terrytornadoTop Contributor
5 Feb 2010 13:48:01 GMT
5 Feb 2010 13:48:01 GMT

Hi Erick,

yes you are right. We have changed an interface. So it should be throw DataAccessExceptions.

public interface HibernateOperations

Helper class that simplifies Hibernate data access code. Automatically converts HibernateExceptions into DataAccessExceptions, following the org.springframework.dao exception hierarchy. 

We will have a look on it.

Thanks
Stephan

terrytornadoTop Contributor
6 Feb 2010 12:01:31 GMT
6 Feb 2010 12:01:31 GMT

Fixed!

Problem was a false Hibernate Dialect (H2 for our Postgres) . Now it's a DataAccessException ConstraintViolation. That's right.

We have a special script that do the deployment of the app on our web server in following way:

a) checkout the project from SF
b) compiles the project
c) replace the file 'customizeApplicationContext.xml' with a modified file that let connect the zksample2 app to
our postgres Database. So the svn Zksample2 sources can run out of the box with the configured H2 Database.
We have now moved the hibernate properties (hibernate.Dialect; hibernate.show_SQL; hibernate.format_SQL) in this file too.
d) copy the .war file to tomcat wepapps directory.

By the way:
For all who are interested in the newest Spring libs.
Björn made at time the Zksample2 sources ready for Spring 3.0 and Spring-Security 3.0x
At time the spring-security pieces of zkspring.jar 1.0 + 1.2 are not all compatible with Spring-Security 3.0x because the spring developers
have renamed some packages.
For us it's no problem because we don't use all of it. The SpringUtils.getBean() method we have cuted and use them.
For method securing with the annotation @Secured() we have an own method that runs all times in the actual Zksample2 codes.

best
Stephan

terrytornadoTop Contributor
7 Feb 2010 11:45:05 GMT
7 Feb 2010 11:45:05 GMT

Done!

The Zksample2 app is updated to Spring3.

Thanks to Björn.

Best
Stephan

erickmelo
9 Feb 2010 15:11:33 GMT
9 Feb 2010 15:11:33 GMT

Hi,

I'm having problems to run the project... I think some maven dependency is missing:
Exception to start the app:

Error creating bean with name 'serviceTxAdvice': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate3.HibernateTransactionManager] for bean with name 'transactionManager' defined in class path resource [applicationContext-db.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.

terrytornadoTop Contributor
9 Feb 2010 15:49:10 GMT
9 Feb 2010 15:49:10 GMT

Update the maven dependencies for both projects.
So it's new libs, so maven must download it first to its local repository.

<Eclipse> <zkoss> <right click> <Maven> <Update Dependencies>
<Eclipse> <spring-hibernate-backend> <right click> <Maven> <Update Dependencies>

best
Stephan


Let me hear if it 's OK.

erickmelo
17 Feb 2010 07:52:40 GMT
17 Feb 2010 07:52:40 GMT

Hi Stephan,

Thank you.. The project is working right now!!

I was looking for your code and I think you made a really good job!! Are you considering create a skeleton project? You created a interesting structure for create ZK projects (with CRUD operations). The GUI classes, Util classes, Pagination classes, Menu classes, Security classes and User authentication are common for many projects. I think a skeleton project (without domais classes - just the packages for insert then) would help many developers to create ZK projects based in Spring and Hibernate. It could be a framework for some kinds of ZK projects.

Suggestion for ZK Studio and ZK Grails team: follow this project structure to automatize the creation of CRUD ZK projects...


Best,
Erick

1 2 3 4 5 7