You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcos Mendonça <ma...@gmail.com> on 2007/08/09 23:02:48 UTC

s:iterator tag

Hello

I'm going crazy trying to use the s:iterator tag.

I have an action that generates an ArrayList of the files in a given directory.

In my JSP I'd like to show this files as a list.

Here's my action's code:

File dir = new File(props.getProperty("files.saveDir"));

FileFilter fileFilter = new FileFilter() {
public boolean accept(File file) {
            return file.getName().endsWith(".gpx");
}
};

File[] f = dir.listFiles(fileFilter);

ArrayList<File> files = new ArrayList(Arrays.asList(f));

return SUCCESS;

And the JSP code:

<s:iterator value="files">
    <s:property />
</s:iterator>


But it show absolutely nothing....
I tried using <s:property value="name"/> instead, but it doesn't work
either. I also trying using JSTL's c:forEach with no success either.

I'm going desperate here, it should be so simple, yet nothing I tried
works. Please, give me a hand.

Much appreciated.

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: s:iterator tag

Posted by Marcos Mendonça <ma...@gmail.com>.
I managed to make it work by acessing the ArrayList.iterator() method.
That is, I had to create another class member of the type Iterator,
create getters and setters for it, and the use that member in the
.jsp.

On 8/9/07, Marcos Mendonça <ma...@gmail.com> wrote:
> Yes, I did. ArrayList has something in it.
>
> I managed to print it's size and log the file name, the one I'd like
> to print with the JSP.
>
> On 8/9/07, Dave Newton <ne...@yahoo.com> wrote:
> > --- Marcos Mendonça wrote:
> > > I have an action that generates an ArrayList of the
> > > files in a given directory.
> >
> > Do you know that it's generating a list with any files
> > in it (determine via logging for the most complete
> > information or put something else in the
> > <s:iterator.../> loop as a quick sanity check)?
> >
> > d.
> >
> >
> >
> >
> > ____________________________________________________________________________________
> > Need a vacation? Get great deals
> > to amazing places on Yahoo! Travel.
> > http://travel.yahoo.com/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: s:iterator tag

Posted by Marcos Mendonça <ma...@gmail.com>.
Yes, I did. ArrayList has something in it.

I managed to print it's size and log the file name, the one I'd like
to print with the JSP.

On 8/9/07, Dave Newton <ne...@yahoo.com> wrote:
> --- Marcos Mendonça wrote:
> > I have an action that generates an ArrayList of the
> > files in a given directory.
>
> Do you know that it's generating a list with any files
> in it (determine via logging for the most complete
> information or put something else in the
> <s:iterator.../> loop as a quick sanity check)?
>
> d.
>
>
>
>
> ____________________________________________________________________________________
> Need a vacation? Get great deals
> to amazing places on Yahoo! Travel.
> http://travel.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: s:iterator tag

Posted by Dave Newton <ne...@yahoo.com>.
--- Marcos Mendonça wrote:
> I have an action that generates an ArrayList of the
> files in a given directory.

Do you know that it's generating a list with any files
in it (determine via logging for the most complete
information or put something else in the
<s:iterator.../> loop as a quick sanity check)?

d.



       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org