I hope you think this helps, because I do not think you have a technical issue, just a design issue:
" have variable columns which may or may not appear "
Yes that would be a problem for any design review, not something that is a good design.
Like how would you unit test the bean outside of the view/JSP? Field1, field2, etc..?

Tech: Struts can and does work with collections, "my" formbeans implement collection so they can multi row update and multi row validate, this includes working the the logic iterate tag and html indexed tag. (you know where this bean implementation is)

I can't see why you would mix logic iterate w/ display tag.

Maybe it is easier to write several JSP/bean combos to do the same? Also, I imagine a good sql command could resolve your issue, optional joins, renamed columns, unions, correlated, etc. etc. Hope you have SQL experience, to help you with design that matches your view requirement.

.V




McLure, David wrote:
Both of these solutions are a little cleaner in terms of JSP, but my real
problem is the underlying Java code with its 30 property getter and setters
(this was the code which set off the code review alarm bells). Ideally, I
think I need to combine something similar to the examples you two supplied
in combination with a Java array in the bean which links to an associated
array in my data object.

I was hoping to avoid the use of scriptlets altogether (which is why I
resorted to individual properties like this to begin with), but I don't see
that happening due to the apparent problems combining the display tag with
the Struts iterate tag. This is the real problem, but life is a story full
of Workarounds.

Thanks!

Dave McLure


-----Original Message-----
From: edgar [mailto:edgar@;blue-moose.net]
Sent: Saturday, November 09, 2002 11:15 AM
To: 'Struts Users Mailing List'
Subject: RE: Making peace between Struts logic iterate and Ed Hill's
display tag...


Wouldn't this work. Still ugly but if you use XML syntax might be
passable.

<%
FooBarBean fooBarBean =
(FooBarBean)request.getAttribute(FooBarBean.LOOKUP_KEY);
%>
<display:table name="FooBarBean" property="fundList" cellspacing="1"
cellpadding="0" border="0" width="569" styleClass="DataTableBorder"
scope="request">
<!-- <display : table name="FooBarBean" cellpadding="4"
property="fundList" width="550" scope="request"> -->
<tr><td class="FooBarTableTitle" height="20">&nbsp;Beautiful Looking
Spreadsheet in the Broswer Brought to you by Hideously Ugly Looking
Code</td></tr>
<display:setProperty name="basic.show.header" value="true" />
<display:column property="fundCode" align="right" styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
title="FooBar Code" />
<%
for (int j = 0 ; j < 30 ; j++ ) {
if (FooBarBean.isExistingColumn(j)) { String fillJ = (j < 10 ? "0" + j : j);
%>
<display:column
property="stuff<%=fillJ%>" align="right" styleClass="FooBarStyle"


headerStyleClass="FooBarDataHeader"
title="Stuff <%=fillJ%>"

/>
<%
}
}
%>
<display:column property="fundTotal" align="right" styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
title="FooBar Total" />
</display:table>

-----Original Message-----
From: Antoni Reus [mailto:antoni.reus@;wanadoo.es]
Sent: Saturday, November 09, 2002 11:19 AM
To: Struts Users Mailing List
Subject: Re: Making peace between Struts logic iterate and Ed Hill's
display tag...


I don't understant why you can't use logic:iterate tag.
Anyway, why don't you use a "for" instead of all those "if", something like this ?


<%!
// Convert a int to a 2 digit String
private String int2DString(int i) {
String number = new Integer(i).toString();
if ( i < 10) {
number = "0" + number;
}
}

private String propName(int i) {
i++; // i was zero-based
return "stuff" + int2DString(++i);
}

private String propTitle(int i) {
i++; // i was zero-based
return "Stuff " + int2DString(++i);
}
%>

<%
FooBarBean FooBarBean =
(FooBarBean)request.getAttribute(FooBarBean.LOOKUP_KEY);
%>

<display:table
name="FooBarBean"
property="fundList"
cellspacing="1"
cellpadding="0"
border="0"
width="569"
styleClass="DataTableBorder"
scope="request">

<tr>
<td class="FooBarTableTitle" height="20">
&nbsp;Beautiful Looking Spreadsheet in the Broswer
Brought to you by Hideously Ugly Looking Code
</td>
</tr>

<display:setProperty name="basic.show.header" value="true" />

<display:column
property="fundCode"
align="right"
styleClass="FooBarStyle"
headerStyleClass="FooBarDataHeader"
title="FooBar Code" />

<% for (int i = 0; i < 30 ; i++) { %>

<% if (FooBarBean.isExistingColumn(i)) { %>

<display:column
property="<%=propName(i)%>"
align="right"
styleClass="FooBarStyle"
headerStyleClass="FooBarDataHeader"
title="<%=propTitle(i)%>" />

<% } // end If %>

<% } // End For %>

<display:column
property="fundTotal"
align="right"
styleClass="FooBarStyle"
headerStyleClass="FooBarDataHeader"
title="FooBar Total" />

</display:table>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to