<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hello Asger,<br>
<br>
maybe the "ResourceInit Handler" can help you.<br>
<br>
What is a ResourceInit handler ?<br>
<ul>
<li> It allows to read a different resource than the one shown
in the URI</li>
<li> "Normal" behaviour of OpenCms:</li>
<ul>
<li> The URI maps to a resource in the VFS</li>
<li> If the URI maps to a non existing file in the VFS, a
404-Error is thrown</li>
</ul>
<li> With a ResourceInit handler, we can use a “virtual” URI
that does not exist in the VFS</li>
</ul>
<p>Example:<br>
<br>
<a class="moz-txt-link-abbreviated" href="http://www.myserver.com/opencms/opencms/index.html">www.myserver.com/opencms/opencms/index.html</a><br>
<br>
is mapped to<br>
</p>
<p>/sites/default/index.html<br>
</p>
<p>With ResourceInit Handler the following is possible:<br>
</p>
<p><a class="moz-txt-link-abbreviated" href="http://www.myserver.com/opencms/opencms/special/index.html">www.myserver.com/opencms/opencms/special/index.html</a><br>
</p>
<p> is mapped to<br>
</p>
<p>/sites/default/internal/specialfolder/index.html<br>
</p>
<p>But the URI keeps the same!<br>
</p>
<p>Implementation & Configuration<br>
</p>
<ul>
<li>ResourceInit Handler must implement the interface
org.opencms.main.I_CmsResourceInit and the method initResource<br>
Is configured in the opencms-system.xml: <br>
</li>
</ul>
<p> <resourceinit><br>
...<br>
<resourceinithandler class="com.alkacon.MyInitHandler"/><br>
...<br>
</resourceinit><br>
</p>
<p>Multiple ResourceInit handlers can configured<br>
</p>
<ul>
<li>Handlers will executed in the order of the configuration</li>
<li>ResourceInit hander analyses the URI and returns a CmsResource</li>
<li>Each handler should have an exclusive trigger in the URI which
signals that it should be used</li>
</ul>
<p>Code example<br>
</p>
<p>public class MyInitHandler implements I_CmsResourceInit {<br>
<br>
/** trigger path. */<br>
public static final String HANDLER_PATH = “/special/";<br>
<br>
public CmsResource initResource(CmsResource resource,<br>
CmsObject cms,<br>
HttpServletRequest request,<br>
HttpServletResponse response) throws CmsResourceInitException {<br>
</p>
<p> // only process this handler if there is a real request<br>
if (request != null) {<br>
String uri = cms.getRequestContext().getUri();<br>
<br>
// only process those requests that start with the
trigger path<br>
if (uri.startsWith(HANDLER_PATH)) {<br>
</p>
<p> // extract the uri of the resource we really
wanted to read<br>
uri = uri.substring(HANDLER_PATH.length(),
uri.length());<br>
// do your implementation here<br>
<br>
}<br>
}<br>
return resource;<br>
}<br>
}<br>
</p>
<p><br>
In your implementaion you should extract your product id form the
url and save (for example as a reqeust attribute) so that you can
access it in your jsp again.</p>
<p><br>
</p>
<p>Kind regards,</p>
<p>Michael Emmerich<br>
</p>
<p></p>
<blockquote cite="mid:546CCDCF-D15D-4317-880E-6AB890F73BCD@tmnet.dk"
type="cite">
<pre wrap="">Hi,
I’m looking to build a website where roughly half the content will come from a backend system, namely products and categories.
I’m not keen to synchronize these to OpenCMS, as the backend already provides the Webservice / EJB interfaces I need.
I can easily make the whole thing work, if I create a custom function (“DisplayProduct.jsp”) that takes a partnumber as a query parameter, look up the data, and render it accordingly.
However, I would like to get a nice looking URL for the data; and I’m willing to limit the product display urls to one subfolder, i.e.
/opencms/opencms/<etc>/products/AB123124
with AB123124 being the partnumber of the product.
Now, ideally, I would be able to register a 404 handler in the products subfolder, and use the PATH_INFO to get the missing bit (AB123124), but I can’t grog how I can do that nicely.
Is this possible?
Or could I somehow just register all the SEO urls from the backend somewhere, and have them all map to the DisplayProduct.jsp (preferably not as mod_rewrite or some such).
Med venlig hilsen/Best Regards
Asger Jensen
Head of Production
E-mail: <a class="moz-txt-link-abbreviated" href="mailto:akj@tmnet.dk">akj@tmnet.dk</a>
Mobile: +45 2630 6502
Niels Hemmingsens Gade 9
1153 København K | Denmark
+45 3344 8555 | <a class="moz-txt-link-abbreviated" href="http://www.tmnet.dk">www.tmnet.dk</a>
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
<a class="moz-txt-link-freetext" href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a>
</pre>
<br>
<pre class="moz-signature" cols="72">--
Alkacon Software GmbH - The OpenCms Experts
Michael Emmerich
Email: <a class="moz-txt-link-abbreviated" href="mailto:m.emmerich@alkacon.com">m.emmerich@alkacon.com</a>
<a class="moz-txt-link-freetext" href="http://www.alkacon.com">http://www.alkacon.com</a>
<a class="moz-txt-link-freetext" href="http://www.opencms.org">http://www.opencms.org</a>
Geschäftsführer: Alexander Kandzior, Amtsgericht Köln, HRB 54613
</pre>
</blockquote>
</body>
</html>