velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "don" <...@cameronsoftware.com>
Subject Veclocity and Object properties in ArrayList
Date Fri, 17 Oct 2003 17:03:27 GMT
I am having problems getting properties from objects which are put into an
ArrayList.  Here is the code which creates the ArrayList:

 

 

ArrayList lImages = new ArrayList();

 

for (int i=0; i<6; i++) {

ImageRef lImage = new ImageRef("Test"+i+".jpg", "This is a test "+i);

            lImages.add(lImage);

}

lContext.put("images", lImages);

 

 

This is the class for the ImageRef:

 

            private class ImageRef {

 

                        private String _FileName;

                        private String _Caption;

 

                        private ImageRef() {}

 

                        public ImageRef(String aFileName, String aCaption) {

                                    _FileName = aFileName;

                                    _Caption = aCaption;

                        }

 

                        public String getFileName() {

                                    return _FileName;

                        }

 

                        public String getCaption() {

                                    return _Caption;

                        }

            }

 

 

This is the velocity template:

 

#foreach ($image in $images)

            $image.caption

$image.Caption

$image.getCaption()     

            #end

        

Which produces the result:

 

 

            $image.caption

            $image.Caption

            $image.getCaption()     

            $image.caption

            $image.Caption

            $image.getCaption()     

            $image.caption

            $image.Caption

            $image.getCaption()     

            $image.caption

            $image.Caption

            $image.getCaption()     

            $image.caption

            $image.Caption

            $image.getCaption()     

            $image.caption

            $image.Caption

            $image.getCaption()     

 

I have gone through the manual, but with no luck. Any ideas?

 

Thanks

Don

 

 

 

 

 

Don Cameron

Director - Sr. Software Architect

Cameron Software Ltd.

 

(250) 889-2480

don@cameronsoftware.com

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message