Hello, I wanted to have links inside the DefaultDataTable cells and I followed advice provided in following link: http://cwiki.apache.org/WICKET/adding-links-in-a-defaultdatatable.html
I could successfully get the links to new pages in the data table. But now if I click these links to open other page. I would need to utilize the model associated with that link to open correct page. Thats when I get a error saying org.hibernate.LazyInitializationException: could not initialize proxy - no Session As far as my understanding goes, we need two things here: 1. OpenSessionInViewFilter - I have it configured in web.xml (oh ya, the filter-mapping element above the Wicket Filter's filter-mapping element)<http://www.nabble.com/OpenSessionInView-and-LazyInitializationException-td17103665.html#a17103665> 2. Usage of LoadableDetachableModels - I have used those. If I debug my code: ---------------- 1. public LinkPanel(String id, final IModel model) { 2. final Item item = (Item) model.getObject(); 3. Link link = new Link("itemLink", model) { 4. @Override 5. public void onClick() { 6. Item item = (Item) getModelObject(); 7. getRequestCycle().setResponsePage(new ItemPage(item.getItemId())); 8. } 9. }; 10. link.add(new Label("label", item.getItemId())); 11. add(link); 12. } ----------------- If I have a breakpoint on line 6. before execution of the line 6, this.getModel() <== evaluates to ==> (jpetstore.page.DetachableItemModel) Model:classname=[jpetstore.page.DetachableItemModel]:*attached=false:* tempModelObject=[null] But when I execute line 6 I would get the LazyInitializationException. Full stacktrace: ERROR: 2008-08-13 00:01:34,687: apache.wicket.RequestCycle: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = itemLink, page = jpetstore.page.ProductPage, path = 2:items:rows:4:cells:1:cell:itemLink.LinkPanel$1, isVisible = true, isVersioned = true]] threw an exception org.apache.wicket.WicketRuntimeException: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = itemLink, page = jpetstore.page.ProductPage, path = 2:items:rows:4:cells:1:cell:itemLink.LinkPanel$1, isVisible = true, isVersioned = true]] threw an exception at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:194) at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:90) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1166) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1241) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1316) at org.apache.wicket.RequestCycle.request(RequestCycle.java:493) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:354) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:111) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:404) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:183) ... 27 more Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111) at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150) at jpetstore.domain.Item$$EnhancerByCGLIB$$e5138583.getAttribute1(<generated>) at jpetstore.page.ItemPage.<init>(ItemPage.java:25) at jpetstore.page.LinkPanel$1.onClick(LinkPanel.java:22) at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:214) ... 32 more Any help is appriciated. Regards, Vijay Dharap
