From: Lane S. <la...@op...> - 2004-03-04 18:24:55
|
Jim et al: Version 2.0 has a new servlet which is an order of magnitude simpler than WMServlet. a) It does not have "magic" in a base class. b) It will parse and render *.html, *.htm, *.{anyWebMacro} as in http://host/index.html c) It has a default implementation so you can use it as is. d) You can override its "process" method. e) It shows how to use an encapsulation of the WebMacro interface using the class, WMEval. This encapsulation lends to the brevity of this servlet. In a future release, I am going to add two interfaces which will be optional: PreWebRequest and PostWebResponse. o.w.servlet.TemplateServlet.java for the goods. Just looking at this servlet will show you how to render a page using WebMacro as a big HELPER. -Lane Keats wrote: >One small correction on my previous post. You'll probably want to store and >retrieve the Hibernate Session using the context rather than an instance >variable (very bad idea -- not thread-safe). E.g., > >public void destroyContext (WebContext wc) >{ > Session hsess = (Session)wc.get("hsess"); > if (hsess != null) hsess.close(); >} > >Keats > >----- Original Message ----- >From: "Keats" <ke...@xa...> >To: <web...@li...> >Sent: Thursday, March 04, 2004 12:08 PM >Subject: Re: [WebMacro-user] Lazy loading when using Webmacro with Hibernate > > > > >>WMServlet has a method called destroyContext() that was created for >> >> >exactly > > >>this kind of thing. Just override the method and do any cleanup that you >>need to happen after the request is handled, like: >> >>public void destroyContext (WebContext wc) >>{ >>hibernateSession.close(); >>} >> >>This will get called by the doRequest() method after the handle() method >>finishes. >> >>Hope this helps. >> >>Keats >>----- Original Message ----- >>From: "c k" <woo...@ho...> >>To: <web...@li...> >>Sent: Wednesday, March 03, 2004 7:29 PM >>Subject: [WebMacro-user] Lazy loading when using Webmacro with Hibernate >> >> >> >> >>>I create servlets which extend WMServlet. In the handle() method, I put >>>POJOs fetched from Hibenate session into Webmacro context and just >>> >>> >return > > >>>to let Webmacro render the page. But it reports "lazy loading problem, >>>session closed". So how can I close the Hibernate session after the >>> >>> >whole > > >>>page has been rendered, override certain method in WMServlet or some >>> >>> >other > > >>>way around? I just don't know where to put Hibernate's session.close() >>> >>> >to > > >>>prevent lazy loading problems. >>> >>>Any help is appreciated. >>> >>>Jim Lee >>> >>> >>> > > > >------------------------------------------------------- >This SF.Net email is sponsored by: IBM Linux Tutorials >Free Linux tutorial presented by Daniel Robbins, President and CEO of >GenToo technologies. Learn everything from fundamentals to system >administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >_______________________________________________ >Webmacro-user mailing list >Web...@li... >https://lists.sourceforge.net/lists/listinfo/webmacro-user > > > -- Lane Sharman For Protection from SPAM and Virus, Extend to the Network Your Perimeter of Defense: http://www.opendoors.com 858-755-2868 |