Cms:contentaccess

(Difference between revisions)
Jump to: navigation, search
(Added category)
(Formatting)
Line 7: Line 7:
 
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.
Line 32: Line 34:
 
: The provided Map key is assumed to be a String that represents the xpath to the value.
 
: 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:
 
: Usage example on a JSP with the JSTL:
  &lt;cms:contentload ... &gt;
+
<code lang="html4strict">
       &lt;cms:contentaccess var="content" /&gt;
+
  <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.
 
; getValueList: Returns a lazy initialized Map that provides Lists of values from the XML content in the current locale.
Line 41: Line 45:
 
: Use this method in case you want to iterate over a List of values form the XML content.
 
: 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:
 
: Usage example on a JSP with the JSTL:
  &lt;cms:contentload ... &gt;
+
<code lang="html4strict">
     &lt;cms:contentaccess var="content" /&gt;
+
  <cms:contentload ... >
     &lt;c:forEach var="teaser" items="${content.valueList['Teaser']}"&gt;
+
     <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 ]]
 
[[Category:Developing in OpenCms ]]

Revision as of 11:21, 16 October 2012

(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.

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):

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.
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.
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>
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