From: Lane S. <la...@op...> - 2005-05-18 00:32:54
|
On a further note, new developers should look at o.w.servlets.TemplateServlet in WM 2, which provides an alternative to subclassing WMServlet. It uses an interface delegate, ServletRouter, to accept delegation calls if defined. If there is an implementation of ServletRouter, it will trap all requests. The implementation of this type is a single method handle(...) method. All of the plumbing for global processing, broker iniitialization, etc, etc, is handled in TemplateServlet. TS can serve up any type of page, including, of course, static HTML pages. The context is a web context, of course. This kind of composition I think makes it a little easier to work with a servlet and WM at the same time. -Lane Keats Kirsch wrote: > Change your code to: > > WM _wm = new WM(this); > > and you should be able to use all the WebContextTools that you care to > configure. > > Keats > > Peter Smith wrote: > >> I think I've failed to effectively communicate my >> situation. Here's another try: >> >> Is it possible to implicitly access the HttpServletRequest object >> in a WebMacro template (in a servlet environment), just as in a JSP >> page? >> >> My servlet extends only HttpServlet, and I create a WM >> instance within my servlet's init() method using the >> following code: >> >> WM _wm = new WM(); >> >> I presume that manually putting the HttpServletRequest >> object into the Context will work for me, but I want >> to know if I can get away with not doing that - like I >> can with defining global 'Functions' in >> WebMacro.properties. >> >> Thanks! >> >> >> >> --- Keats Kirsch <ke...@xa...> wrote: >> >> >>> From: Keats Kirsch <ke...@xa...> >>> To: web...@li... >>> Subject: Re: Fwd: [WebMacro-user] how to use Request >>> and other 'special objects'? >>> Date: Tue, 17 May 2005 13:14:26 -0400 >>> >>> WM basically operates in two modes, Servlet or >>> stand-alone, depending on how you initialize the WM object. If you >>> instantiate WM with a Servlet instance, it can access the the Web >>> application >>> context, so it uses a WebContext and tools that rely on this, like the >>> RequestTool, SessionTool, CookieTool, etc, will work. If you >>> extend WMServlet, this happens automatically. >>> >>> Hope this helps. >>> >>> Keats >>> >>> Peter Smith wrote: >>> >>> >>> >>>> Seems I've gotten a bit closer. I added the >>>> >>> >>> following >>> >>> >>>> entry to my WebMacro.defaults: >>>> >>>> >>>> >>> >> ContextTools.Request=org.webmacro.servlet.RequestTool >> >> >>>> This I decided to do after finding an email in the >>>> archives referring to: >>>> >>>> ContextTools.Manipulate: >>>> com.acme.wm.ContextManipulator >>>> >>>> But this produces the following error: >>>> >>>> context ERROR Unable to initialize ContextTool: >>>> Request >>>> org.webmacro.PropertyException: This only works >>>> >>> >>> with >>> >>> >>>> WebContext >>>> java.lang.ClassCastException... >>>> >>>> What am I missing? >>>> >>>> >>>> --- Peter Smith <sh...@ya...> wrote: >>>> >>>> >>>> >>>> >>>>> From: Peter Smith <sh...@ya...> >>>>> To: web...@li... >>>>> Subject: [WebMacro-user] how to use Request and >>>>> other 'special objects'? >>>>> Date: Tue, 17 May 2005 08:26:29 -0700 (PDT) >>>>> >>>>> Looking for some doc on using Request and other >>>>> 'context tools' - couldn't find on site. >>>>> First question - can I pass anything other than >>>>> Strings as arguments to my globally-defined >>>>> >>>> >>> template >>> >>> >>>>> functions? I'm getting the following error when >>>>> trying to pass '$Request' as an argument: >>>>> >>>>> ============ >>>>> java.lang.UnsupportedOperationException: Cannot >>>>> invoke toString() on an undefined variable. >>>>> ============ >>>>> >>>>> Thanks. >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>> >> >> ------------------------------------------------------- >> >> >>> This SF.Net email is sponsored by Oracle Space >>> Sweepstakes >>> Want to be the first software developer in space? >>> Enter now for the Oracle Space Sweepstakes! >>> >>> >> >> http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click >> >> >>> _______________________________________________ >>> Webmacro-user mailing list >>> Web...@li... >>> >>> >> >> https://lists.sourceforge.net/lists/listinfo/webmacro-user >> >> >> >> --peter-- http://shmooth.blogspot.com/ >> >> >> >> Yahoo! Mail >> Stay connected, organized, and protected. Take the tour: >> http://tour.mail.yahoo.com/mailtour.html >> >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by Oracle Space Sweepstakes >> Want to be the first software developer in space? >> Enter now for the Oracle Space Sweepstakes! >> http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click >> _______________________________________________ >> Webmacro-user mailing list >> Web...@li... >> https://lists.sourceforge.net/lists/listinfo/webmacro-user >> >> >> > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by Oracle Space Sweepstakes > Want to be the first software developer in space? > Enter now for the Oracle Space Sweepstakes! > http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click > _______________________________________________ > Webmacro-user mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webmacro-user > |