tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From C.H._C...@promos.com.tw
Subject Re: Scope with DBtags
Date Tue, 21 Aug 2001 00:13:41 GMT


Try disabling looping and manipulate the resultSet manually.
Change the code
  <sql:resultSet id="rset2">
to  <sql:resultSet id="rset2" loop="false">
    <% ResultSet rset22 = (ResultSet)pageContext.getAttribute("rset2");
       ....
    %>




|--------+----------------------->
|        |          Mark Shead   |
|        |          <MarkS@reslif|
|        |          e.org>       |
|        |                       |
|        |          2001/08/20   |
|        |          11:08 PM     |
|        |          Please       |
|        |          respond to   |
|        |          taglibs-user |
|        |                       |
|--------+----------------------->
  >----------------------------------------------------------------------|
  |                                                                      |
  |       To:     taglibs-user@jakarta.apache.org                        |
  |       cc:     (bcc: C.H. CHOU/ProMOS)                                |
  |       Subject:     Scope with DBtags                                 |
  >----------------------------------------------------------------------|





I'm running into an odd problem that I think has something to do with the
way scope works within the DBtags.  I need to create a variable to total the
cost for a list of items.  If I create a variable called total outside of
the DBtags, it doesn't seem to be in scope within  the loop that is
generating the rows of my table.  The same thing is happening with int a
that I am trying to use to alternate the bgcolor of my table.

Any suggestions?

--Mark

Here is the code:

   <%
     int a = 0;
     float total = 0; *********************************************
declaration
   %>

   <sql:resultSet id="rset2">
           <%

     total=total+rset2.getFloat("expected_cost"); *** why isn't it in scope
here?
     a = a + 1;
     if(a%2!=0) {%>
       <tr bgcolor="#FFFFCC">
         <% }else {%>
       <tr bgcolor="#CCFFCC"><%}%>
         <td><sql:getColumn colName="description"/></td>
         <td><sql:getColumn colName="vendor"/></td>
         <td><sql:getColumn colName="expected_cost"/></td>
         <td><a href="delete_req_item.jsp?req_item_id=<sql:getColumn
colName="req_item_id"/>">delete </a></td>
       </tr>
     </sql:resultSet>
</sql:statement>

      <tr bgcolor="#CCCCFF">
      <td></td>
      <td align=RIGHT><b>Total:</b></td>*************** why isn't
it in
scope here?
      <td><b><%=total%></b></td>
      <td></td>
   </tr>




Mime
View raw message