Class CmsJspResourceAccessBean
- java.lang.Object
-
- org.opencms.jsp.util.CmsJspResourceAccessBean
-
public class CmsJspResourceAccessBean extends java.lang.Object
Allows access to the attributes and properties of a resource, usually used inside a loop of a<cms:resourceload>
tag.The implementation is optimized for performance and uses lazy initializing of the requested values as much as possible.
- Since:
- 8.0
- See Also:
CmsJspTagResourceAccess
-
-
Constructor Summary
Constructors Constructor Description CmsJspResourceAccessBean()
No argument constructor, required for a JavaBean.CmsJspResourceAccessBean(CmsObject cms, CmsResource resource)
Creates a content access bean based on a Resource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CmsObject
getCmsObject()
Returns the OpenCms user context this bean was initialized with.CmsFile
getFile()
Returns the raw VFS file object of the current resource.java.lang.String
getFileContentAsString()
Returns the file contents of the raw VFS file object as String.java.lang.String
getFilename()
Returns the site path of the current resource, that is the result ofCmsObject.getSitePath(CmsResource)
with the resource obtained bygetFile()
.java.util.Map<java.lang.String,java.lang.String>
getHistoryProperty()
Short form forgetReadHistoryProperties()
.java.util.Map<java.lang.String,java.lang.String>
getProperty()
Short form forgetReadProperties()
.java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
getPropertyLocale()
Short form forgetReadPropertiesLocale()
.java.util.Map<java.lang.String,java.lang.String>
getReadHistoryProperties()
Returns a map that lazily reads history properties of the resource.java.util.Map<java.lang.String,java.lang.String>
getReadProperties()
Returns a map that lazily reads properties of the resource.java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
getReadPropertiesLocale()
Returns a map that lazily reads properties of the resource and makes the accessible according to the specified locale.CmsResource
getResource()
Returns the current resource.CmsJspVfsAccessBean
getVfs()
Returns an instance of a VFS access bean, initialized with the OpenCms user context this bean was created with.void
init(CmsObject cms, CmsResource resource)
Initialize this instance.
-
-
-
Constructor Detail
-
CmsJspResourceAccessBean
public CmsJspResourceAccessBean()
No argument constructor, required for a JavaBean.You must call
init(CmsObject, CmsResource)
and provide the required values when you use this constructor.- See Also:
init(CmsObject, CmsResource)
-
CmsJspResourceAccessBean
public CmsJspResourceAccessBean(CmsObject cms, CmsResource resource)
Creates a content access bean based on a Resource.- Parameters:
cms
- the OpenCms context of the current userresource
- the resource to create the content from
-
-
Method Detail
-
getCmsObject
public CmsObject getCmsObject()
Returns the OpenCms user context this bean was initialized with.- Returns:
- the OpenCms user context this bean was initialized with
-
getFile
public CmsFile getFile()
Returns the raw VFS file object of the current resource.This can be used to access information from the raw file on a JSP.
Usage example on a JSP with the JSTL:
<cms:resourceload ... > <cms:resourceaccess var="res" /> Root path of the resource: ${res.file.rootPath} </cms:resourceload>
- Returns:
- the raw VFS file object the content accessed by this bean was created from
-
getFileContentAsString
public java.lang.String getFileContentAsString()
Returns the file contents of the raw VFS file object as String.Usage example on a JSP with the JSTL:
<cms:resourceload ... > <cms:resourceaccess var="res" /> String content of the resource: ${res.fileContentAsString} </cms:resourceload>
- Returns:
- the file contents of the raw VFS file object as String
-
getFilename
public java.lang.String getFilename()
Returns the site path of the current resource, that is the result ofCmsObject.getSitePath(CmsResource)
with the resource obtained bygetFile()
.Usage example on a JSP with the JSTL:
&<cms:resourceload ... > <cms:resourceaccess var="res" /> Site path of the resource: "${res.filename}"; </cms:resourceload>
- Returns:
- the site path of the current resource
- See Also:
CmsObject.getSitePath(CmsResource)
-
getHistoryProperty
public java.util.Map<java.lang.String,java.lang.String> getHistoryProperty()
Short form forgetReadHistoryProperties()
.This works only if the current resource is implementing
I_CmsHistoryResource
.Usage example on a JSP with the
<cms:resourceaccess>
tag:<cms:resourceload ... > <cms:resourceaccess var="res" /> History "Title" property value of the resource: ${res.historyProperty['Title']} </cms:resourceload>
- Returns:
- a map that lazily reads history properties of the resource
- See Also:
getReadHistoryProperties()
-
getProperty
public java.util.Map<java.lang.String,java.lang.String> getProperty()
Short form forgetReadProperties()
.Usage example on a JSP with the
<cms:resourceaccess>
tag:<cms:resourceload ... > <cms:resourceaccess var="res" /> "Title" property value of the resource: ${res.property['Title']} </cms:resourceload>
- Returns:
- a map that lazily reads properties of the resource
- See Also:
getReadProperties()
-
getPropertyLocale
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getPropertyLocale()
Short form forgetReadPropertiesLocale()
.Usage example on a JSP with the
<cms:resourceaccess>
tag:<cms:resourceload ... > <cms:resourceaccess var="res" /> "Title" property value of the resource: ${res.property['de']['Title']} </cms:resourceload>
- Returns:
- a map that lazily reads properties of the resource and accesses them wrt. to the specified locale.
- See Also:
getReadPropertiesLocale()
-
getReadHistoryProperties
public java.util.Map<java.lang.String,java.lang.String> getReadHistoryProperties()
Returns a map that lazily reads history properties of the resource.This works only if the current resource is implementing
I_CmsHistoryResource
.Usage example on a JSP with the
<cms:resourceaccess>
tag:<cms:resourceload ... > <cms:resourceaccess var="res" /> History "Title" property value of the resource: ${res.readHistoryProperties['Title']} </cms:resourceload>
- Returns:
- a map that lazily reads properties of the resource
- See Also:
for a short form of this method
-
getReadProperties
public java.util.Map<java.lang.String,java.lang.String> getReadProperties()
Returns a map that lazily reads properties of the resource.Usage example on a JSP with the
<cms:resourceaccess>
tag:<cms:resourceload ... > <cms:resourceaccess var="res" /> "Title" property value of the resource: ${res.readProperties['Title']} </cms:resourceload>
- Returns:
- a map that lazily reads properties of the resource
- See Also:
for a short form of this method
-
getReadPropertiesLocale
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getReadPropertiesLocale()
Returns a map that lazily reads properties of the resource and makes the accessible according to the specified locale.Usage example on a JSP with the
<cms:resourceaccess>
tag:<cms:resourceload ... > <cms:resourceaccess var="res" /> "Title" property value of the resource: ${res.readProperties['de']['Title']} </cms:resourceload>
- Returns:
- a map that lazily reads properties of the resource and makes the accessible according to the specified locale.
- See Also:
for a short form of this method
-
getResource
public CmsResource getResource()
Returns the current resource.Usage example on a JSP with the JSTL:
&<cms:resourceload ... > <cms:resourceaccess var="res" /> Root path of the resource: "${res.resource.rootPath}"; </cms:resourceload>
- Returns:
- the current resource
-
getVfs
public CmsJspVfsAccessBean getVfs()
Returns an instance of a VFS access bean, initialized with the OpenCms user context this bean was created with.- Returns:
- an instance of a VFS access bean, initialized with the OpenCms user context this bean was created with
-
init
public void init(CmsObject cms, CmsResource resource)
Initialize this instance.- Parameters:
cms
- the OpenCms context of the current userresource
- the resource to create the content from
-
-