-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I want to understand how the MVC pattern works with Spring + Hibernate, by analyze the code generated by Zeta Form Building.
Someone can tell me which annotation were used to do the relation between UI (.zul file) and the Controller, and how it work?
Thanks in advance ...
I've just try to upgrade an fail:
What's about xmlns:zksp-annot="http://www.zkoss.org/2008/zkspring-annot namespace?
It seems that the core contains the annotations to (scopes, appliedto) but there is no component-scan command in the core-defintion.
However i failed without the component-scan line with: (tested including and exlcuding the zkspringannot jar)
SCHWERWIEGEND: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'zkTypePropertyEditor': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.HashMap' to required type 'java.util.Map' for property 'customEditors'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.Class] to required type [java.lang.String] for property 'customEditors[class java.lang.Class]': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:643)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
The Map/Hashmap seems a Spring issue 2.x/3.x, check this side.
My Config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:zkspc="http://www.zkoss.org/2008/zkspring/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd
http://www.zkoss.org/2008/zkspring/core
http://www.zkoss.org/2008/zkspring/core/zkspring-core.xsd">
...
<zkspc:zk-config/>
...
Versions:
ZK 5.0.4 Std
Spring 3.0.3
ZKSpring 3.0RC
Config created by zeta and modified - removed old spring and zkspring jars.
The projects starts ok, when i exclude the the line <zkspc:zk-config/>.
So i think, it is not possible to run the zetaforms with spring 3.x (with the current version).
/Robert
I've just testet the annotations (@controller, scope idspace) with 5.0.4:
It works with both
5.0.4 EE and
5.0.4 Standard (requires an manuell copy from the commons-collection)
but i used the old spring version. I'll try the upgrade later.
Note: Upgrade Spring/Hibernate could be a painfull job, because there are many dependcies...
I have a working Spring 3/Hibernate 3.5.1/JPA 2.0 project, but i use ZK 3.6.3 and none of these annotations.
/Robert
Hi dandrop,
Please note that since 3.0RC zkspring is split into two namespaces viz. zkspring-core and zkspring-security. To be more specific your namespace declaration in applicationContext.xml reads
xmlns:zksp="http://www.zkoss.org/2008/zkspring
xmlns:zkspc="http://www.zkoss.org/2008/zkspring/core
http://www.zkoss.org/2008/zkspring/core http://www.zkoss.org/2008/zkspring/core/zkspring-core.xsd
All these specifics are noted in detail on the ZKSpring docs page. If there are any more questions/problems feel free to post here.
Thanks
Hi Jimmy!
Yes, i did.
Today i tried again create a project! I did this procedure!
Install ZK Package 5.0.4 in preference in Eclipse!
Create a Zk Project called "zk5spring"
Add all jar of spring-framework-3.0.2.RELEASE-with-docs
Add a jar for zk-spring-core-bin-3.0RC
I try too add the jar of zk-spring-security-bin-3.0RC
Create file applicationContext.xml
"<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:zksp="http://www.zkoss.org/2008/zkspring"
xmlns:zksp-annot="http://www.zkoss.org/2008/zkspring-annot"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.zkoss.org/2008/zkspring
http://www.zkoss.org/2008/zkspring/zkspring.xsd
http://www.zkoss.org/2008/zkspring-annot
http://www.zkoss.org/2008/zkspring-annot/zkspring-annot.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
>
<!--
ZK Spring config
<zksp-annot:component-scan base-package="org.zkoss.spring.jpa"/>
-->
<zksp:zk-config/>
<!-- other bean definitions -->
<bean id="DataSourceTest" class="test.DataSourceImpl" />
</beans>"
Config the web.xml file.
"<!-- Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>"
I run using Apache tomcat v6.0.20 and JBoss 4.2.3.GA and the both aprear the error message
"cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'zksp:zk-config'."
Thanks for you help.
\Danilo
Hi Danilo
Did you download the latest zkspring ?
Robert,
Thanks for to reply!
I'm using the ZK 5, and I tried with version CE and PE and it didn't work!
I try create a simple project with ZK Studio Project, putting the spring jar's and make the configuration of file "applicationContext.xml" with the tag <zksp:zk-config/> and nothing! Error! :(
The configuration of my project is Spring 3 + JPA 2.0 + Hibernate 3, and only this function isn't work!
I used some features of ZK 5 and because of it, I can't make the downgrade! I will continue find the solution or wait for a new version for zkspring.jar integration that resolves it.
Are you using the version EE in your project ? If you have access could you try with this version!
/Thanks
/Danilo
1.) What version of ZK you are using?
2.)
a.) This could be a missing zk namepace inside the application-context.xml. (let zeta create the spring config and create at least one form)
b.) Maybe the annotation don't work anymore or the syntax have changed - because the specs was not final.
3.) If I have some time, i'll try to check this with a new version. I've only tested this features and not used in productive envirnoment (cause unfinished specs).
@ZKTeam
4.) Any news about an official launch?
/Robert
Here a minimal example:
[and once more: SPECS ARE NOT FINAL]
index.zul
<?page title="Index" contentType="text/html;charset=UTF-8"?> <zk> <window id="indexWin" title="Index" border="normal"> <label id="hide" /> <button id="show" label="Show" /> </window> </zk>
IndexController.java
package com.at.od.controller; import javax.annotation.Resource; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import org.zkoss.spring.context.annotation.AfterCompose; import org.zkoss.spring.context.annotation.AppliedTo; import org.zkoss.spring.context.annotation.EventHandler; import org.zkoss.zul.Label; @Scope("idspace") @Controller @AppliedTo("indexWin") public class IndexController { @Resource protected Label hide; @AfterCompose public void afterCompose() { hide.setValue("Start"); } @EventHandler("show.onClick") public void doView() { hide.setValue("Clicked!"); } }
application-context.xml
<zksp-annot:component-scan base-package="org.zkoss.spring.jpa,webtests,com.at.od.controller"/>
<zksp:zk-config/>
Add your package. Check Spring-docs for more (generic) options.
Do you use the zk professional package? (other parts of zeta, don't work with standard-package - i'm not sure about spring).
/Robert
Asked: 2009-04-20 10:00:51 +0800
Seen: 2,385 times
Last updated: Nov 04 '10