[opencms-dev] Request Handlers

Alexander Kandzior alex at opencms.org
Fri Aug 13 21:02:43 CEST 2004


Jason,

the request handlers where added for scenarios where no VFS is available. I
don't think it's a goof idea to extend the use too much.

If you want to start a Java class without a JSP, I would recommend an
approach like this:

- create a new resource type, e.g. "action"
- in the VFS you create instances of this "action" resource type 
  where you need them
- each of the "action" resource type requires a property "actionclass"
- create a resource loader for the "action" resource type
- when a resource type "action" is requested, an instance of the
"actionclass"  
  is generated, which does what you want
- it's probably a good idea to have a certain interface that the
"actionclass"
  must implement
- if required, the content of the file that has the property set can be 
  used as input for the actionclass, but this is optional

Best Regards,
Alex.

Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com

> -----Original Message-----
> From: opencms-dev-bounces at opencms.org 
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Jason Schatz
> Sent: Friday, August 13, 2004 6:50 PM
> To: opencms-dev at opencms.org
> Subject: [opencms-dev] Request Handlers
> 
> 
> I've checked out the HEAD from cvs and have been playing around with 
> request handlers.  I am using the request handlers to process 
> requests 
> submitted from HTML forms.  Ideally, I would like all form 
> requests go 
> to compiled Java code (such as the request handlers) and I would then 
> like the ability for the response to be rendered using a standard VFS 
> resource (so that the rendering of the response can take advantage of 
> the templates and other stuff I already have set up in 
> OpenCMS).  In MVC 
> terms, the request handler acts as my Controller that can 
> hook up with 
> and manipulate my Model and then pass off the rendering of 
> the response 
> to the View which is a standard OpenCMS resource.
> 
> In order to achieve the last piece, the ability for the 
> handler to use 
> an existing resource to render the response, I had to add a 
> method with 
> the following signature to the OpenCmsCore object:
> 
> public void showResource(HttpServletRequest req, HttpServletResponse 
> res, String viewPath)
> 
> which allows the request handler to process the request and 
> the provide 
> a path to a jsp to display the response.
> I would like to know whether the way that I'm using request 
> handlers is 
> one of the intended uses or whether I should be using some other 
> mechanism.  The bigger question is whether this means of 
> accomplishing 
> MVC is consistent with your direction for OpenCMS.  If so, would you 
> accept a patch with the changes outlined above.
> Eventually I would like to be able to add request handlers during 
> runtime rather then having to specify them beforehand in the 
> opencms-system.xml file.  I would be willing to work on a patch to 
> achieve this behavior as well.
> --Jason
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, 
> please visit http://mail.opencms.org/mailman/listinfo/opencms-dev
> 
> 




More information about the opencms-dev mailing list