[opencms-dev] more questions on path conversion

Christoph P. Kukulies kuku at physik.rwth-aachen.de
Wed Mar 22 17:28:22 CET 2006


On Wed, Mar 22, 2006 at 05:07:30PM +0100, Christoph P. Kukulies wrote:
> Thanks to recent help from this list and a code snippet I found while
> digging in the archives I'm stuck with the following problem:
> 
> 
> CmsJspActionElement cms =
>    new CmsJspActionElement(pageContext, request, response);
>    String currentUri = cms.getRequestContext().getUri();
>    CmsObject o = cms.getCmsObject();
>       String strPagename = cms.getRequestContext().getUri();
>       out.write(currentUri + "<br>");
>       List siblings = o.readSiblings(strPagename, CmsResourceFilter.ALL);
>       for (int i = 0, l = siblings.size(); i < l; i++) {
>                 String vfsName =
> ((CmsResource)siblings.get(i)).getRootPath();
>                 out.write(vfsName + "<br>");
>         }
> 
> gives me e.g.:
> 
> /de/index.html
> 
> /sites/mysite/de/index.html
> /sites/mysite/en/index.html
> 
> 
> With what method() di I get rid of the /sites/mysite prefix?
> 

I tried to help myself with the following:

CmsRequestContext rec=cms.getRequestContext();
...
String vfsName =
 rec.removeSiteRoot(((CmsResource)siblings.get(i)).getRootPath());


It worked but maybe there is a simpler solution?

--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de



More information about the opencms-dev mailing list