Hi we have been starting with our hibernate/spring/wicket app a few weeks ago and its quite easy. We do it with maven2 like this:
i show you some snippets, please ask me if you have any further questions: in your pom.xml: ========================= <properties> <wicket.version>1.4.5</wicket.version> </properties> ... <dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket</artifactId> <version>${wicket.version}</version> </dependency> <dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket-extensions</artifactId> <version>${wicket.version}</version> </dependency> <dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket-spring</artifactId> <version>${wicket.version}</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> </exclusions> </dependency> web.xml ========================= <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>wicket</display-name> <filter> <filter-name>wicket.wicket</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value>org.yourapp.MyApplication</param-value> </init-param> </filter> <filter-mapping> <filter-name>wicket.wicket</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> you can start the spring context directly in your web.xml, but I wanted to start my SpringApplication manually in my Application class: in your MyApplication.java ========================= public class MyApplication extends WebApplication @Override protected void init ( ) { WebApplicationContext ctx = start_your_spring_context_here addComponentInstantiationListener(new SpringComponentInjector(this, ctx, true)); } @Override public RequestCycle newRequestCycle ( Request request, Response response ) { return new HibernateRequestCycle(this, (WebRequest) request, (WebResponse) response); } our session per RequestCycle Implemenatation: ========================= public class HibernateRequestCycle extends WebRequestCycle { SessionFactory sessionFactory; public HibernateRequestCycle ( JlotApplication application, WebRequest request, Response response ) { super(application, request, response); this.sessionFactory = (SessionFactory) application.getApplicationContext().getBean("sessionFactory"); } @Override protected void onBeginRequest ( ) { if (!TransactionSynchronizationManager.hasResource(sessionFactory)) { Session session = SessionFactoryUtils.getSession(sessionFactory, true); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); } super.onBeginRequest(); } @Override protected void onEndRequest ( ) { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory); SessionFactoryUtils.closeSession(sessionHolder.getSession()); super.onEndRequest(); } } wherever you need a Spring bean you can inject it like this: @SpringBean Repository repository; public MyClass() { InjectorHolder.getInjector().inject(this); } if you have a wicket component you do not need this line: InjectorHolder.getInjector().inject(this); then read about detachable Models! Its quite important to understand it if you use hibernate. we use an entityModel like this one: http://wicketinaction.com/2008/09/building-a-smart-entitymodel/ if you like i can send you more source code, but i got it working just by reading "wicket in action", which is am excellent book. our software will be open source soon, so i can send you the complete source code if you like. kind regards Janning On Thursday 24 December 2009 06:42:57 Johan den Boer wrote: > Hi > > I am looking for a real working example on wicket and hibernate. I have > read the books 'Wcket in Action', 'Pro Wicket' and other books but none of > them give a real working example. Can somebody point me to a real working > example or can sent to me. > > The most problem i have with the configuration in web.xml and using the > spring integration. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org