Re: Question about Struts <logic:iterate> tag



"javadude" <chris@xxxxxxxxxxxx> wrote:

> request.setAttribute("foos", fooList);
> // forward to JSP for display
>
> In my JSP, I want to iterate over and display the Foo objects and
> display their IDs.
>
> I have:
> <logic:iterate id="nextElement" name="foos">
> <br>NextFoo<bean:write name="nextElement" property="id" /></b>
> </logic:iterate>
>
> However, I get the error:
> Cannot find bean nextElement in any scope'

You code (slightly modified) worked fine for me, so my guess is that
something's NQR with how you're filling the List or placing it in the
request. That or the code you posted isn't actually the code that's
producing the error.

Here's some code you can include at the bottom of your JSP...
http://wiki.wendysmoak.com/cgi-bin/wiki.pl?DebugJSP
It just prints out everything in the request/session/context... make sure
everything is where you think it is.

For starters, try just <bean:write name="foos" /> and make sure it can find
the list, and that the list has what you think it has in it. Hopefully your
'Foo' class has a good 'toString' method.

(You don't have to <jsp:usebean> with the Struts tags, it knows how to look
in the various scopes to find objects. Anyway, it's not complaining about
'foos', it's complaining about 'nextElement' inside the iteration.)

--
Wendy Smoak


.



Relevant Pages

  • Re: Question about Struts tag
    ... The jsp has to know where to access the bean. ... >I have an action class that creates an ArrayList of Foo objects and ... > // forward to JSP for display ...
    (comp.lang.java.programmer)
  • Question about Struts tag
    ... I have an action class that creates an ArrayList of Foo objects and ... then sets them in the request. ... // forward to JSP for display ...
    (comp.lang.java.programmer)
  • Re: Creating 2 D arraylist
    ... If I use EL to display the arraylist in JSP, ... Your strategy seems to be to layout the table column by column and row by row in your data structure. ... Another strategy is to use a JSP layout that maps value object attributes to columns of the table. ... An EL, really we mean a JSTL, works best with a list where each column maps to an attribute of a value object, where the row represents the public interface of the object, rather than a 2-D list. ...
    (comp.lang.java.programmer)
  • Re: Why read CLC?
    ... To get a consultant job today, you must correctly answer six screening questions: ... SET foo TO TRUE. ... or do you get a compilation error? ... DISPLAY foo. ...
    (comp.lang.cobol)
  • Re: IE displaying syntax instead of parsed page layout
    ... have xhtml page which, ... The JSP which generated this page also generates it as readonly (no input ... this DOES display OK on IE.. ... evidently the way to go (searched for examples on removing frames and css). ...
    (alt.html)