[opencms-dev] extracting Property attributes from within a JSP

mfoley5 at csc.com.au mfoley5 at csc.com.au
Wed Sep 18 04:32:45 CEST 2002


Hi Rod,

You could try something like:

com.opencms.flex.cache.CmsFlexRequest req
= (com.opencms.flex.cache.CmsFlexRequest)request;
com.opencms.file.CmsObject cms = req.getCmsObject();
String docRole  = cms.readProperty(cRes.getAbsolutePath(),"Role");

Here we have created another property called "Role" which contains string
info.  You can equally well use this for default properties, such as
"Title" and "Description".

Regards,
Mark

Mark Foley
__________________________________________________
CSC
212 Northbourne Ave, Braddon, ACT 2612
Ph: +61-2-62468487    Email: mfoley5 at csc.com.au
----------------------------------------------------------------------------------------

This email, including any attachments, is intended only for use by the
addressee(s) and may contain confidential and/or personal information and
may also be the subject of legal privilege. Any personal information
contained in this email is not to be used or disclosed for any purpose
other than the purpose for which you have received it. If you are not the
intended recipient, you must not disclose or use the information contained
in it. In this case, please let me know by return email, delete the message
permanently from your system and destroy any copies.
----------------------------------------------------------------------------------------


                                                                                                                                            
                      "Rod Thorburn"                                                                                                        
                      <rod.thorburn at pavtech.        To:       <opencms-dev at opencms.com>                                                     
                      co.nz>                        cc:                                                                                     
                      Sent by:                      Subject:  [opencms-dev] extracting Property attributes from within a JSP                
                      owner-opencms-dev at www.                                                                                                
                      opencms.org                                                                                                           
                                                                                                                                            
                                                                                                                                            
                      18/09/2002 09:53 AM                                                                                                   
                      Please respond to                                                                                                     
                      opencms-dev                                                                                                           
                                                                                                                                            
                                                                                                                                            




I am exploring the jsp functionality in opencms5_beta to build a dynamic
directory listing (based on the flex-examples that came with the
distribution). The following code snippet returns the Description, Title
and NavText elements for each .html file in the directory /news/articles/


      // Link substitutor to make sure static export works
      com.opencms.util.LinkSubstitution subst = new
      com.opencms.util.LinkSubstitution();
      // Collect the objects required to access the OpenCms VFS from the
      request
      com.opencms.flex.cache.CmsFlexRequest req
      = (com.opencms.flex.cache.CmsFlexRequest)request;
      com.opencms.file.CmsObject cms = req.getCmsObject();
      com.opencms.file.CmsFile file = req.getCmsFile();

      // Get the folder name
      String foldername = "/news/articles/";

      // Get a list of all pages / subfolders in the folder (sorted by
      NavPos property)
      java.util.ArrayList list =
      CmsJspNavElement.getNavigationForFolder(cms, foldername);
      java.util.Iterator i = list.iterator();
      while (i.hasNext())
      {
          CmsJspNavElement ne = (CmsJspNavElement)i.next();
          %><p>
              <%=ne.getDescription() != null ? ne.getDescription() : ""
      %><br>
              <%=ne.getTitle() != null ? ne.getTitle() : "" %><br>
              <a href="<%=subst.getLinkSubstitution(cms, ne.getResourceName
      ())%>"><%=ne.getNavText() != null ? ne.getNavText() : "" %
      ></a>
          </p><%
      }





What I also want to do is extract or use other Property values for a given
.html file, that are not defined by CmsJspNavElement.java . For example , I
may have created a Property called "Date", or I might want to select only
certain .html files by a value in the "Key Words" Property.


The temtation is to call the method getProperty() , but this method is not
defined in the CmsJspNavElement class (as far as I can determine it is only
available in CmsJspTagUser.java) .


Does anyone know of a way of accessing additional file Properties in the
above context without writing additional code in the appropriate classes?


Rod









More information about the opencms-dev mailing list