[opencms-dev] <cms:contentshow element="Link"/>

Fabian Huschka fhsubscriptions at componio.net
Wed Jun 29 15:28:30 CEST 2011


 Hi,

please use the filetranslator or

String uri = cms.getRequestContext().getUri();
String tempUri= cms.getRequestContext().removeSiteRoot(uri);

to get rid of a potential site root. In your case there is surely no
"/sites/default" in the URI thus the IndexOutOfBounds exception as you
try to access the second element which does not exist.
The rest of the code looks ok.

\Fabian



On 29.06.2011 15:11, Raghu D wrote:
> CmsJspActionElement cms = new CmsJspActionElement (pageContext,
> request, response);
> CmsObject cmso = cms.getCmsObject();
> String uri = cms.getRequestContext().getUri();
> String tempUri= uri.split("/sites/default")[1] ;
> CmsFile file = cmso.readFile(tempUri)   ;
> CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(cmso,file);
> String message = xmlContent.getValue("Link", enLocale,
> 0).getStringValue(cmso); 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20110629/23203625/attachment.htm>


More information about the opencms-dev mailing list