You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by chuanjiang lo <lo...@gmail.com> on 2007/01/26 04:17:36 UTC
Iterate over a file list
Hi all,
I have an ArrayList (fileList) that stores the type java.io.File
Im trying to iterate through the list to get the name and size of the file
<logic:iterate id="file" name="fileList" >
<bean:write name="file" property="name" />
</logic:iterate>
java.io.File provides a method length() that return us the size of the file.
So how i can get the size of the file?
i tried <bean:write name="file" property="length" /> and the error prompts
that there isnt a getter method for length.
Any ideas?
Re: Iterate over a file list
Posted by Paul Benedict <pb...@apache.org>.
Properties must begin with "get" -- which means "length" is not a
property. You will have to use scriptlets, or wrap your File in some
class which can expose a getter for you.
chuanjiang lo wrote:
> Hi all,
>
> I have an ArrayList (fileList) that stores the type java.io.File
>
> Im trying to iterate through the list to get the name and size of the file
>
> <logic:iterate id="file" name="fileList" >
> <bean:write name="file" property="name" />
> </logic:iterate>
>
> java.io.File provides a method length() that return us the size of the
> file.
>
> So how i can get the size of the file?
> i tried <bean:write name="file" property="length" /> and the error prompts
> that there isnt a getter method for length.
>
> Any ideas?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org