[opencms-dev] How to get property values of files in vfs

Thomas Fabbricante tom_fabbricante at wunderman.com
Thu Mar 18 21:21:01 CET 2004


Added the one line to cast to CmsResource, and it works like a charm.

Thanks!
-tom

for(int i=0;i<numFiles ;i++){
      //out.println(files.get(i).toString());
       // files is a Vector of com.opencms.file.CmsFile objects.
       CmsResource res = (CmsResource)files.get(i);
       String filename = res.getAbsolutePath();
       String title = cmso.readProperty(filename, propertyname);
       // Do whatever...

  }



                                                                                                                  
                    M Butcher                                                                                     
                    <mbutcher at grcomputi       To:     opencms-dev at opencms.org                                     
                    ng.net>                   cc:                                                                 
                    Sent by:                  Subject:     Re: [opencms-dev] How to get property values of files  
                    opencms-dev-admin at o        in vfs                                                             
                    pencms.org                                                                                    
                                                                                                                  
                                                                                                                  
                    03/18/2004 03:15 PM                                                                           
                    Please respond to                                                                             
                    opencms-dev                                                                                   
                                                                                                                  
                                                                                                                  





I'm working from memory here, so you'd better read the Javadocs first,
but...

import com.opencms.file.CmsObject;

CmsObject cmso = cms.getCmsObject();
String propertyname = "Title";
 > Vector files = cms.getFilesInFolder(targetFolder);
 > int numFiles = files.size();
 >
 > for(int i=0;i<numFiles ;i++){
 >     //out.println(files.get(i).toString());
       // files is a Vector of com.opencms.file.CmsFile objects.
       String filename = files.get(i).getAbsolutePath();
       String title = cmso.readProperty(filename, propertyname);
       // Do whatever...
 >
 > }

The CmsObject is really important, but it's not really covered in the
docs that well. You'll definitely want to read the Javadocs for it --
you'll find it helpful.

Matt



Thomas Fabbricante wrote:
> I would like to read the values of a few properties in a vector of files.
>
> I'm having trouble getting the properties from each resource.
>
> I think I have to use the CmsJspTagInfo object but I'm not sure how to
get
> there.
>
> ..................................
> Vector files = cms.getFilesInFolder(targetFolder);
> int numFiles = files.size();
>
> for(int i=0;i<numFiles ;i++){
>     //out.println(files.get(i).toString());
>
>     ?????????.getProperty();
> }
> ..................................
>
>
>
> Much appreciated,
> -tom
>
>
>
>
>
> ===============================================
> This transmission is confidential and intended
> solely for the person or organization to whom
> it is addressed.  It may contain privileged and
> confidential information.  If you are not the
> intended recipient, you should not copy,
> distribute or take any action in reliance on it.
>
> If you have received this transmission in error,
> please notify the sender at the e-mail address above.
> ================================================
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev

_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://mail.opencms.org/mailman/listinfo/opencms-dev





=============================================
This transmission is confidential and intended
solely for the person or organization to whom
it is addressed.  It may contain privileged and
confidential information.  If you are not the
intended recipient, you should not copy,
distribute or take any action in reliance on it.

If you have received this transmission in error,
please notify the sender at the e-mail address above.
==============================================




More information about the opencms-dev mailing list