You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David McLure <da...@mclures.net> on 2002/11/09 15:59:18 UTC

Making peace between Struts logic iterate and Ed Hill's display tag...

Last month a fellow by the name of Rick Ruemann [maillist@reumann.net]
posted a reply to an email inquiry of mine, turning me on to Ed Hill's
marvelous display tag library (Hi Rick!).  It turns out that Ed's web
site URL is actually http://edhill.its.uiowa.edu/display-0.8/  (implying
that Ed might have even a newer version of the tag library now, but I
digress...)  :

>From: Rick Reumann [maillist@reumann.net]
>Sent: Thursday, October 10, 2002 8:02 PM
>To: Struts Users Mailing List
>Subject: Re: Ideas for doing a spreadsheet-styled tables using Struts
tags
>
>On Thursday, October 10, 2002, 7:55:21 PM, David wrote:
>
>DM> I am currently looking for ideas on ways to display potentially
>DM> large amounts of data in a spreadsheet format using Struts.
>
>    Check out using this display tag:
>    http://edhill.its.uiowa.edu/display/
>
>    I couldn't live without it:) (Even will provide a link that you
>    can click on to export the display to Excel).
>
>    Excellent tag.
>
>--
>
>Rick
>mailto:maillist@reumann.net

Since then, with Rick's help (and Rick deserves a lot of credit for
figuring out how to use this display tag library by the way), I have
managed to implement the display tag in my Struts based application and
it seems to work just fine.  The problem?  My code is ugly as sin!  It's
so bad, that after glancing over my shoulder the other day, one of my
best friends at work (Hi Russ!) has already warned me that it will
undoubtedly fail the upcoming code review.  He's got a point too - it is
Coyote Ugly Code!

The reason is that neither Rick nor I have figured out a way to make Ed
Hill's display tag live peacefully with Struts logic iterate tags.  As a
result, I have JSP code which looks something like the following :

<%
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" />
    <% if (FooBarBean.isExistingColumn(0)) { %>
   <display:column property="stuff01" align="right"
styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
title="Stuff 01" />
    <% } if (FooBarBean.isExistingColumn(1)) { %>
   <display:column property="stuff02" align="right"
styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
title="Stuff 02" />
    <% } if (FooBarBean.isExistingColumn(2)) { %>
   <display:column property="stuff03" align="right"
styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
title="Stuff 03" />
   ...etc., etc...
    <% } if (FooBarBean.isExistingColumn(29)) { %>
   <display:column property="stuff30" align="right"
styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
title="Stuff 30" />
    <% } %>
    <display:column property="fundTotal" align="right"
styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
title="FooBar Total" />
</display:table>

... and Java code to support this which is simply to hideous looking to
post in front of a family audience... (Russ happened to catch me
desparately trying to prettify the most hideous looking class of the
bunch!  There are some things which simply no combination of comments
can help :-).

So please, just shoot me already!  Either that, or help me with this
agonizing problem which is causing me to lose sleep (normally I sleep
late on Saturday mornings if I stay up late the night before).  Of
course, it doesn't help that in this case, I have variable columns which
may or may not appear (causing the need for the additional "if
(FooBarBean.isExistingColumn(x))" scriptlet code.  Even without that
problem though, it seems that I would still end up having to in line my
display columns with silly looking class properties like stuff00,
stuff01, stuff02, etc., all the way to stuff29 for each of my 30
possible data columns when I would normally write a much sexier loop
through an array (or even sexier - a collection) - all because Struts
logic:iterate tags don't seem to want to play with the display:column
tags!

We have tried asking Ed Hill about this problem, but Ed has been pretty
busy lately (either that, or it is entirely possible that our emails to
him at his email address posted on his web site are being lost in
mountains of junk mail - which is the problem I am faced with on one of
my more well known web site email accounts - making useful
correspondence with me almost impossible to that email address).  Ed,
are you still with us?

Anyway, as my code review approaches, I thought I'd try one last time to
spare this otherwise extremely powerful display tag library from the
hungry jaws of the code reviewers at work.  Of course, I could just rip
out the display tag altogether and be done with it, but by doing so, I
would also sacrifice the use of the display taglib's spreadsheet (XML,
XLS, etc.) file export features (along with potentially many other nice
features).  The business group at work would not be happy with the loss
of these features.

Has anyone ever had any luck using Ed Hill's display tag library with
the Struts logic:iterate tag?  If so, then please reply to this post and
also contact me directly at my work address (david.mclure@fmr.com).

Thanks!

Dave McLure
Fidelity Investments
(aka david.mclure@fmr.com)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Making peace between Struts logic iterate and Ed Hill's display tag...

Posted by Antoni Reus <an...@wanadoo.es>.
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>


A Dissabte 09 Novembre 2002 15:59, David McLure va escriure:
> Last month a fellow by the name of Rick Ruemann [maillist@reumann.net]
> posted a reply to an email inquiry of mine, turning me on to Ed Hill's
> marvelous display tag library (Hi Rick!).  It turns out that Ed's web
> site URL is actually http://edhill.its.uiowa.edu/display-0.8/  (implying
> that Ed might have even a newer version of the tag library now, but I
> digress...)  :
>
> From: Rick Reumann [maillist@reumann.net]
>
> >Sent: Thursday, October 10, 2002 8:02 PM
> >To: Struts Users Mailing List
> >Subject: Re: Ideas for doing a spreadsheet-styled tables using Struts
>
> tags
>
> >On Thursday, October 10, 2002, 7:55:21 PM, David wrote:
> >
> >DM> I am currently looking for ideas on ways to display potentially
> >DM> large amounts of data in a spreadsheet format using Struts.
> >
> >    Check out using this display tag:
> >    http://edhill.its.uiowa.edu/display/
> >
> >    I couldn't live without it:) (Even will provide a link that you
> >    can click on to export the display to Excel).
> >
> >    Excellent tag.
> >
> >--
> >
> >Rick
> >mailto:maillist@reumann.net
>
> Since then, with Rick's help (and Rick deserves a lot of credit for
> figuring out how to use this display tag library by the way), I have
> managed to implement the display tag in my Struts based application and
> it seems to work just fine.  The problem?  My code is ugly as sin!  It's
> so bad, that after glancing over my shoulder the other day, one of my
> best friends at work (Hi Russ!) has already warned me that it will
> undoubtedly fail the upcoming code review.  He's got a point too - it is
> Coyote Ugly Code!
>
> The reason is that neither Rick nor I have figured out a way to make Ed
> Hill's display tag live peacefully with Struts logic iterate tags.  As a
> result, I have JSP code which looks something like the following :
>
> <%
> 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" />
>     <% if (FooBarBean.isExistingColumn(0)) { %>
>    <display:column property="stuff01" align="right"
> styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
> title="Stuff 01" />
>     <% } if (FooBarBean.isExistingColumn(1)) { %>
>    <display:column property="stuff02" align="right"
> styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
> title="Stuff 02" />
>     <% } if (FooBarBean.isExistingColumn(2)) { %>
>    <display:column property="stuff03" align="right"
> styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
> title="Stuff 03" />
>    ...etc., etc...
>     <% } if (FooBarBean.isExistingColumn(29)) { %>
>    <display:column property="stuff30" align="right"
> styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
> title="Stuff 30" />
>     <% } %>
>     <display:column property="fundTotal" align="right"
> styleClass="FooBarStyle" headerStyleClass="FooBarDataHeader"
> title="FooBar Total" />
> </display:table>
>
> ... and Java code to support this which is simply to hideous looking to
> post in front of a family audience... (Russ happened to catch me
> desparately trying to prettify the most hideous looking class of the
> bunch!  There are some things which simply no combination of comments
> can help :-).
>
> So please, just shoot me already!  Either that, or help me with this
> agonizing problem which is causing me to lose sleep (normally I sleep
> late on Saturday mornings if I stay up late the night before).  Of
> course, it doesn't help that in this case, I have variable columns which
> may or may not appear (causing the need for the additional "if
> (FooBarBean.isExistingColumn(x))" scriptlet code.  Even without that
> problem though, it seems that I would still end up having to in line my
> display columns with silly looking class properties like stuff00,
> stuff01, stuff02, etc., all the way to stuff29 for each of my 30
> possible data columns when I would normally write a much sexier loop
> through an array (or even sexier - a collection) - all because Struts
> logic:iterate tags don't seem to want to play with the display:column
> tags!
>
> We have tried asking Ed Hill about this problem, but Ed has been pretty
> busy lately (either that, or it is entirely possible that our emails to
> him at his email address posted on his web site are being lost in
> mountains of junk mail - which is the problem I am faced with on one of
> my more well known web site email accounts - making useful
> correspondence with me almost impossible to that email address).  Ed,
> are you still with us?
>
> Anyway, as my code review approaches, I thought I'd try one last time to
> spare this otherwise extremely powerful display tag library from the
> hungry jaws of the code reviewers at work.  Of course, I could just rip
> out the display tag altogether and be done with it, but by doing so, I
> would also sacrifice the use of the display taglib's spreadsheet (XML,
> XLS, etc.) file export features (along with potentially many other nice
> features).  The business group at work would not be happy with the loss
> of these features.
>
> Has anyone ever had any luck using Ed Hill's display tag library with
> the Struts logic:iterate tag?  If so, then please reply to this post and
> also contact me directly at my work address (david.mclure@fmr.com).
>
> Thanks!
>
> Dave McLure
> Fidelity Investments
> (aka david.mclure@fmr.com)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>