Cms:contentaccess

From OpenCms Wiki
(Difference between revisions)
Jump to: navigation, search
(From the javadoc)
 
(Formatting)
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
= <cms:contentaccess> =
 
<small>(From the javadocs: http://files.opencms.org/javadoc/core/org/opencms/jsp/CmsJspTagContentAccess.html)</small>
 
<small>(From the javadocs: http://files.opencms.org/javadoc/core/org/opencms/jsp/CmsJspTagContentAccess.html)</small>
  
Line 7: Line 8:
 
For example together with the JSTL, use this tag inside an open tag like this:
 
For example together with the JSTL, use this tag inside an open tag like this:
  
 +
<code lang="html4strict">
 
  <cms:contentload ... >
 
  <cms:contentload ... >
 
     <cms:contentaccess var="myVarName" val="myValueVarName" scope="page" />
 
     <cms:contentaccess var="myVarName" val="myValueVarName" scope="page" />
 
     ... other code ...
 
     ... other code ...
 
  </cms:contentload>
 
  </cms:contentload>
 +
</code>
  
 
The tag is available since OpenCms 7.0.2.
 
The tag is available since OpenCms 7.0.2.
 +
 +
Within this tag, the <tt>CmsJspContentAccessBean</tt> is exposed:
  
 
== CmsJspContentAccessBean ==
 
== CmsJspContentAccessBean ==
Line 23: Line 28:
 
The bean exposes some properties (this is not a comprehensive list):
 
The bean exposes some properties (this is not a comprehensive list):
  
; getCmsObject: Returns the OpenCms user context this bean was initialized with.
+
===CmsObject:getCmsObject()===
 +
Returns the OpenCms user context this bean was initialized with.
  
; getFile: Returns the raw VFS file object the content accessed by this bean was created from.
+
===CmsFile:getFile()===
 +
Returns the raw VFS file object the content accessed by this bean was created from.
  
; getFileName: Returns the site path of the current resource.
+
===String:getFileName()===
 +
Returns the site path of the current resource.
  
; getValue: Returns a lazy initialized Map that provides values from the XML content in the current locale.
+
===Map<String,CmsJspContentAccessValueWrapper>:getValue()===
: The provided Map key is assumed to be a String that represents the xpath to the value.
+
Returns a lazy initialized Map that provides values from the XML content in the current locale.
: Usage example on a JSP with the JSTL:
+
The provided Map key is assumed to be a String that represents the xpath to the value.
  &lt;cms:contentload ... &gt;
+
Usage example on a JSP with the JSTL:
       &lt;cms:contentaccess var="content" /&gt;
+
<code lang="html4strict">
 +
  <cms:contentload ... >
 +
       <cms:contentaccess var="content" />
 
       The Title: ${content.value['Title']}
 
       The Title: ${content.value['Title']}
  &lt;/cms:contentload&gt;
+
  </cms:contentload>
 +
</code>
  
; getValueList: Returns a lazy initialized Map that provides Lists of values from the XML content in the current locale.
+
===Map<String,List<CmsJspContentAccessValueWrapper>>:getValueList()===
: The provided Map key is assumed to be a String that represents the xpath to the value.
+
Returns a lazy initialized Map that provides Lists of values from the XML content in the current locale.
: Use this method in case you want to iterate over a List of values form the XML content.
+
The provided Map key is assumed to be a String that represents the xpath to the value.
: Usage example on a JSP with the JSTL:
+
Use this method in case you want to iterate over a List of values form the XML content.
  &lt;cms:contentload ... &gt;
+
Usage example on a JSP with the JSTL:
     &lt;cms:contentaccess var="content" /&gt;
+
<code lang="html4strict">
     &lt;c:forEach var="teaser" items="${content.valueList['Teaser']}"&gt;
+
  <cms:contentload ... >
 +
     <cms:contentaccess var="content" >
 +
     <c:forEach var="teaser" items="${content.valueList['Teaser']}">
 
         ${teaser}
 
         ${teaser}
     &lt;/c:forEach&gt;
+
     </c:forEach>
  &lt;/cms:contentload&gt;
+
  </cms:contentload>
 +
</code>
 +
 
 +
[[Category:Developing in OpenCms ]]

Latest revision as of 11:25, 16 October 2012

Contents

<cms:contentaccess>

(From the javadocs: http://files.opencms.org/javadoc/core/org/opencms/jsp/CmsJspTagContentAccess.html)

Used to access XML content item information from the current open <cms:contentload> tag using JSP page context and the JSP EL.

The tag will create an instance of a CmsJspContentAccessBean that is stored in the selected context. Use the options provided by the bean to access the XML content directly.

For example together with the JSTL, use this tag inside an open tag like this:

 <cms:contentload ... >
     <cms:contentaccess var="myVarName" val="myValueVarName" scope="page" />
     ... other code ...
 </cms:contentload>

The tag is available since OpenCms 7.0.2.

Within this tag, the CmsJspContentAccessBean is exposed:

CmsJspContentAccessBean

(From the javadocs: http://files.opencms.org/javadoc/core/org/opencms/jsp/util/CmsJspContentAccessBean.html)

Allows access to the individual elements of an XML content.

The implementation is optimized for performance and uses lazy initializing of the requested values as much as possible.

The bean exposes some properties (this is not a comprehensive list):

CmsObject:getCmsObject()

Returns the OpenCms user context this bean was initialized with.

CmsFile:getFile()

Returns the raw VFS file object the content accessed by this bean was created from.

String:getFileName()

Returns the site path of the current resource.

Map<String,CmsJspContentAccessValueWrapper>:getValue()

Returns a lazy initialized Map that provides values from the XML content in the current locale. The provided Map key is assumed to be a String that represents the xpath to the value. Usage example on a JSP with the JSTL:

 <cms:contentload ... >
      <cms:contentaccess var="content" />
      The Title: ${content.value['Title']}
 </cms:contentload>

Map<String,List<CmsJspContentAccessValueWrapper>>:getValueList()

Returns a lazy initialized Map that provides Lists of values from the XML content in the current locale. The provided Map key is assumed to be a String that represents the xpath to the value. Use this method in case you want to iterate over a List of values form the XML content. Usage example on a JSP with the JSTL:

 <cms:contentload ... >
     <cms:contentaccess var="content" >
     <c:forEach var="teaser" items="${content.valueList['Teaser']}">
         ${teaser}
     </c:forEach>
 </cms:contentload>
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox