0

how to integrate zk with spring and hibernate

asked 2006-07-02 01:31:01 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3803918

By: lijunrong

I am ajax learner.And I am researching zk now.When I integrate zk 2.0.0 with spring and hibernate,I successed!.But when I use zk 2.0.1,there are some trouble about Initiator.
My code as follows:

package com.potix.zkdemo.test;


import java.util.Collection;
import com.potix.zul.html.Listbox;
import javax.servlet.ServletContext;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.potix.zk.ui.Page;
import com.potix.zk.ui.util.Initiator;
import com.potix.zkdemo.test.HibernateClinic;

public class AllOwners extends Listbox implements Initiator {
public void doInit(Page page,Object Object[]) {
HibernateClinic clinic =getHibernateClinic() ;
page.setVariable("allOwners", clinic.findOwners(""));
}

public void doCatch(Throwable ex) {
}
public void doFinally() {
}
public HibernateClinic getHibernateClinic() {
ApplicationContext ctx=
WebApplicationContextUtils.getRequiredWebApplicationContext(
(ServletContext)this.getDesktop().getWebApp().getNativeContext());
return (HibernateClinic)
ctx.getBean("clinicTarget",HibernateClinic.class);
}
}

the code: this.getDesktop().getWebApp().getNativeContext() can not work.

Anybody can help me? very thanks!

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2006-07-02 03:19:16 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3803937

By: tomyeh

Spec is changed a bit: when doInit is called, page is not associated with a desktop yet. So, invoke Executions.getCurrent().getDesktop().getWebApp()
instead.

See Java Doc:
http://zk1.sourceforge.net/javadoc/2.0.1/zk/com/potix/zk/ui/util/Initiator.html#
doInit(com.potix.zk.ui.Page,%20java.lang.Object[])

link publish delete flag offensive edit

answered 2006-07-02 06:20:16 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3803976

By: lijunrong

tomyeh:
very thank you. I have resolved this problem according your hints!

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: 2006-07-02 01:31:01 +0800

Seen: 289 times

Last updated: Jul 02 '06

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