[opencms-dev] accessing navInfo or some other property
Pavel Peringer
pavel.peringer at qbizm.cz
Tue Apr 17 08:53:57 CEST 2007
Hello
I suppose that you need this property on request file - URL. Else you
need to use methods wih parameter(path-to-resource).
You have two ways:
1) Use CmsJspNavBuilder
CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext, request, response);
CmsJspNavBuilder cmsNavigation = cmsJsp.getNavigation();
CmsJspNavElement element = cmsNavigation.getNavigationForResource();
String navInfo = element.getInfo();
2) Direct read property with CmsObject
CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext, request, response);
CmsObject cmsObject = cmsJsp.getCmsObject();
CmsRequestContext cmsRequest = cmsJsp.getRequestContext();
String requestFile = cmsRequest.getUri();
CmsResource resource = cmsObject.readResource(requestFile);
String navInfo = cmsObject.readPropertyObject(resource, CmsPropertyDefiniton.PROPERTY_NAVINFO, false).getValue();
I use the second way, because when you read "standard" property
"NavText" and the value is not set on resource, you get to HTML code
OpenCms warning message "+++ File property "{0}" on "{1}" not found.
+++" and " ends string in attribute and HTML is not valid. With second
way you get null or value and output is up to you.
Using readPropertyObject with CmsResource instead of String resourcePath
is DB load optimalization. When you read property with String path,
OpenCms first reads CmsResource and then calls readPropertyObject with
this CmsResource. So you should use readResource and then
readPropertyObject in case you need to read more than one property on
same resource.
HTH
Christoph P. Kukulies napsal(a):
>I need to identify a generated page e.g. by a property, let's take
>navInfo for that purpose.
>
>I have this in my template:
>
>CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
>response);
> CmsObject o = cms.getCmsObject();
>
>How can I access navInfo (using e.g. CmsJspNavelement getInfo())?
>
>
>--
>Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>
>
>_______________________________________________
>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
>http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
--
Bc. Pavel Peringer Qbizm technologies, a.s.
Developer ... the art of software.
____________________________________________________________________
www.qbizm-technologies.cz www.qbizm.cz www.qbizm-services.cz
More information about the opencms-dev
mailing list