Re: Question about Struts <logic:iterate> tag




The jsp has to know where to access the bean. If it is just in the page put
this at the top,
<jsp:useBean id="foos" scope="session" class="java.util.ArrayList"/>


"javadude" <chris@xxxxxxxxxxxx> wrote in message
news:1120144001.686235.291250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>I have an action class that creates an ArrayList of Foo objects and
> then sets them in the request. Note I am putting the list itself
> directly into the request:
>
> FooAction.java:
> List fooList = new ArrayList();
> for (int i = 0; i < 3; i++)
> {
> String id = "ID" + i;
> Foo f = new Foo(id);
> fooList.add(f);
> }
> 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'
>
> What am I doing wrong?
> Thanks in advance.
>


.



Relevant Pages

  • Re: Question about Struts tag
    ... > // forward to JSP for display ... I want to iterate over and display the Foo objects and ... 'Foo' class has a good 'toString' method. ...
    (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: put application on server ??!!!!
    ... > I am new to web service programming and I just start to learn jsp. ... > make my application into a bean? ... separate those two pieces into separate code bases with published APIs ... Have forms submit to servlets. ...
    (comp.lang.java.programmer)
  • Show a bean property in jsf....its so difficult?????
    ... I have a jsf application and i have to show a bean value into a jsp ... public String[] getarraylinee{ ... catch (NullPointerException exc) { ...
    (comp.lang.java.programmer)