The property() method

This method provides access to read the properties of the current file or its parent folders as configured in the "Properties" context menu dialog of the OpenCms explorer view.

Parameters:

Name Description
java.lang.String name The name of the property to read. Common properties are for example "Title", "Keywords", "Description" etc.

Parameters:

Name Description
java.lang.String name see above
java.lang.String file

This parameter allows you to specify where to search for the property.
The following values are supported:

uri (default)
Look up the property on the file with the uri requested by the user.
search.uri or search
Look up the property by also checking all parent folders for the property, starting with the file with uri requested by the user and going "upward" if the property was not found there.
element.uri
Look up the property on the currently processed sub - element. This is useful in templates or other pages that consist of many elements.
search.element.uri
Look up the property by also checking all parent folders for the property, starting with the file with the currently processed sub - element and going "upward" if the property was not found there.
{some-file-uri}
Look up the property on that exact file uri in the OpenCms VFS, fallback if no other valid option is selected for the file attribute.

Parameters:

Name Description
java.lang.String name see above
java.lang.String file see above
java.lang.String defaultValue A default value that is returned in case the property was not found.

Parameters:

Name Description
java.lang.String name see above
java.lang.String file see above
java.lang.String defaultValue see above
boolean escapeHtml If true, HTML characters are escaped by their hexadecimal value (e.g. & becomes & #38;).

 

Example usage:

 

Read the "Title" property of the current file:

org.opencms.jsp.CmsJspActionElement cms = 
new org.opencms.jsp.CmsJspActionElement(pageContext,request, response);

String title = cms.property("Title");

Try to find the "Keywords" property of the current file and, if it is not found there, try to find it on all parent folders:

org.opencms.jsp.CmsJspActionElement cms = 
new org.opencms.jsp.CmsJspActionElement(pageContext,request, response);

String keywords = cms.property("Keywords", "search");