I have made further progress.
To me it looks like jstl issue rather than display tag.
Some how I can not use ${variablename} in display tag.
cout works. but i can not c out inside title.
so following code works - but i am not able to get title. I have hardcoded
title as a. Any help is apprecited
<display:table uid="item" name="items">
<c:forEach var="cl" items="${item.innerBeans }" varStatus="index1">
<display:column title="a"><c:out value="${item.innerBeans [
index1.index].currYearExpenditure}"/></display:column>
</c:forEach>
</display:table>
On 4/24/07, jill juneja <[EMAIL PROTECTED]> wrote:
Thanks Ed for the response.
This assumtion is correct - that all
your bean2 objects have the same number of bean1 beans in their Lists
and they are present in the same order.
I tried your example exactly and it does not work for me.
But I do not get value and in title i get innerBeans[${index}].title
display.
I tried index.index, c.title every thing. But it displays the text as put
in title and property is blank.
The progress i made from my code is it adds three columns, as outerbean as
three elements of inner bean.
On 4/24/07, Ed Webb <[EMAIL PROTECTED]> wrote:
>
> jill juneja wrote:
> > I am sorry, I think I conveyed my need differently. I do not need a
> > decorator.
> >
> > My need is to create columns from database.
> >
> >
> > <display:table name="bean2" >
> > <display:column property="name" title="School Name"
> ></display:column>
> >
> > <c:forEach var="cl" items="bean2.bean1">
> > <display:column title="${cl.title}" property="${cl.value}" />
> > </c:forEach>
> >
> [snip]
> >
> >
> > </display:table>
> >
>
> I think the <display:column> element above is where you're going wrong.
> the property attribute needs to contain the property of bean2 that
> displaytag can use to retrieve the value of the cell. You appear to be
> putting the actual value into the property attribute. In the small
> example below you can see that to reference a bean contained in the
> ArrayList of beans I needed to use innerBeans[${ index.index}].value
> which results in Displaytag calling (for example for the 1st bean in the
> List): getInnerBeans().get(0).getValue(). I am assuming that either you
> have a single bean2 which creates a table with a single row or that all
> your bean2 objects have the same number of bean1 beans in their Lists
> and they are present in the same order. Hope this helps.
>
>
> // File OuterBean.java
>
> package test;
>
> import java.util.ArrayList ;
>
> public class OuterBean {
>
> private ArrayList innerBeans;
>
> public OuterBean() {
> innerBeans = new ArrayList();
> innerBeans.add(new InnerBean("One", 5));
> innerBeans.add (new InnerBean("Two", 6));
> innerBeans.add(new InnerBean("Three", 7));
> }
>
> public ArrayList getInnerBeans() {
> return innerBeans;
> }
> }
>
> //File InnerBean.java
>
> package test;
>
> public class InnerBean {
> private String title;
> private int value;
>
> public InnerBean(String title, int value) {
> this.title = title;
> this.value = value;
> }
>
> public String getTitle() {
> return title;
> }
>
> public int getValue() {
> return value;
> }
> }
>
> // File displaytest.jsp
>
> <%@ taglib uri=" http://java.sun.com/jsp/jstl/core" prefix="c" %>
> <%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
>
> <html>
> <head>
> </head>
> <body>
> <%
> java.util.ArrayList outerBeans = new java.util.ArrayList();
> for (int i = 0; i < 5; i++) {
> outerBeans.add(new test.OuterBean());
> }
> request.setAttribute("items", outerBeans);
> %>
> <display:table uid="item" name="items">
> <c:forEach var="cl" items="${item.innerBeans }"
> varStatus="index">
> <display:column title="${cl.title}"
> property="innerBeans[${index.index}].value" />
> </c:forEach>
> </display:table>
> </body>
> </html>
>
> Ed!
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> displaytag-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user