I made the argument for Custom tags over scriptlets at 
our shop and lost. Soon pages became more and more 
complex and things started to break down. Debugging 
scriptlets is difficult, tools are behind Java tools used 
to develop tags, and for the most part you have all of 
the tag functionality you need with JSTL.

Your Struts example would be improved through the use of 
JSTL and the JSTL expression language. Here is something 
similar with struts:

        <th align="left"><bean-el:message key="text.delete" /></th>
        <th align="left"><bean-el:message key=""
        <th align="left"><bean-el:message key="text.customer.address"
        <th align="left"><bean-el:message key=""
        <th align="left"><bean-el:message key="text.customer.state"
        <th align="left"><bean-el:message key=""
      <c:forEach var="customer" items="${customerListForm.customers}">
          <td><html-el:checkbox styleClass="checkbox"
name="customerListForm" property="deletes" value="${}"
          <td><c:url value="/" var="editlink">
            <c:param name="action" value="update" />
            <c:param name="alpha" value="${customerListForm.alpha}" />
            <c:param name="updateId" value="${}" />
            </c:url> <a href='<c:out value="${editlink}" />'><c:out
value="${}" /></a>
          <td><c:out value="${customer.address1}" /></td>
          <td><c:out value="${}" /></td>
          <td><c:out value="${customer.state}" /></td>
          <td><c:out value="${}" /></td>

There are several advantages here provided by Struts. One 
is that the screen descriptions are softcoded (similar to using MSGID
DDS). Also, this is easy to debug as all logic is in real Java code. 

I don't see it as a problem to say that something you will 
treat as a list has to be either a Collection, Map, Object[], 
String, Array, Iterator or Enumeration. In my example, the 
form supporting the page has a List of Customer objects 
it. The Customer class was generated via Hibernate right 
off the iSeries (or MySql, Oracle, Postgres, etc). 

David Morris

>>> joepluta@xxxxxxxxxxxxxxxxx 10/9/2003 2:02:00 PM >>>
Here's my two cents:

This is an example without Struts:

  List list = dvds.getDVDList();
  for (Iterator i = list.iterator(); i.hasNext();) {
    DVD dvd = (DVD);

This is the same example with Struts:

<logic:iterate id="dvd" name="dvds" property="DVDList">
    <td><bean:write name="dvd" property="title" /></td>
    <td><bean:write name="dvd" property="length" /></td>
    <td><bean:write name="dvd" property="actors" /></td>

The argument for struts is that this is "cleaner".  I guess that's
because it all has nice <tag> and </tag> symmetry.

Personally, I don't much see it being cleaner.  I understand the upper
code better than the lower.  And the lower syntax is very confining,
especially if my classes don't exactly conform to the JavaBean
specification - let's say one of my methods was "calculateTax". 
I change that method name to "getTax", I will not be able to create a
<bean:write> tag for it.  Also, my object of type "dvds" has to be of
specific interface - one that supports the "iterator" method.

I suggest taking a LOT of time to read the Struts tag library to make
sure you realize what you're getting yourself into.  Struts is fine if
you like having your language dictate how you write your application.
Me, I'll stick with my own code.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.