In addition to the other resources I listed, you should take a look at JSTL:
  http://java.sun.com/products/jsp/jstl/

The reference implementation for JSTL is at Jakarta taglibs:
  http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html

In particular, look at the iteration tag <c:forEach> which is roughly
equivalent to Struts <logic:iterate> tag.
Both can be used to generate your result table by iterating over a
collection.

For example, using JSTL:
If 'widgetResults' is the name of a Collection of Widgets in some scope
(page, request, session, application) then you could use the JSTL tags in
the following extract to display a table containing the Widget details:

<%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt"; prefix="fmt" %>

...
<c:if test="${empty widgetResults}">
  <p>No widgets found.</p>
</c:if>

<c:if test="${not empty widgetResults}">
  <table>
  <tr>
    <th>SKU</th>
    <th>Color</th>
    <th>Size</th>
    <th>Description</th>
    <th>Price</th>
  </tr>
  <c:forEach var="widget" items="${widgetResults}">
  <tr>
    <td><c:out value="${widget.SKU}"/></td>
    <td><c:out value="${widget.color}"/></td>
    <td><c:out value="${widget.size}"/></td>
    <td><c:out value="${widget.description}"/></td>
    <td><fmt:formatNumber type="currency" value="${widget.price}"/></td>
  </tr>
  </c:forEach>
</table>
</c:if>
...

This will print out a row in the table for each Widget in your Collection.

JSTL requires JSP 1.2 or later and you should use it in preference to the
Struts tag libraries where you can.

Steve

http://www.ninsky.com/struts/



> -----Original Message-----
> From: Seshadhri Srinivasan [mailto:[EMAIL PROTECTED]
> Sent: August 25, 2003 11:51 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Struts custom tags tutorial
>
>
> Hi Steve,
> Let me clarify:
>       I know some of the basic concepts of struts and I have been using
> things like the Action class, the Form class etc. But the point is, after
> having finished the work on the backend logic, I have to present
> my data in
> the form of tables on the page. Now the table dimensions, the
> colours used,
> etc. can vary based on the data generated. So I wanted to use
> custom Struts
> tags on the page where the table has to be generated and displayed. Then I
> want to put my code corresponding to these struts tags else
> where. This way
> the logic to display the data will not be there on the JSP page.
> This is my
> problem. I have tried to get the right tutorial for this but my search has
> noy yielded the right results. Can you please help me.
>
> Thanks,
> Seshadhri Srinivasan
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to