I'm new to struts, I'm trying to use the iterate tag with to retrieve data
from a db and display it. We have the functionality working with our java
classes and now I'm trying to incorporate it using struts. The following
code illustrates how we are doing it now.

<%
                try {
                        sai.db.IRecordIterator it =
invoiceService.getStatusSummary();
                        while (it.next()!=null) {
                                aig.its.db.RecordInvoice rec =
(aig.its.db.RecordInvoice) it.current();
                
                                 %>
                <td class="ft"><%=rec.getGroupCount ()%></td>
                <td class="ft">$<%=rec.getGroupSum
(aig.its.db.Tables.Invoice.InvoiceTotal).setScale(2,java.math.BigDecimal.ROU
ND_DOWN)%></td>
                </tr><%
                
                if (currentSwapColor==0) currentSwapColor=1; else
currentSwapColor=0;
                        }
                }
                catch (java.sql.SQLException E) {
                        %><%=E.toString()%><%
                }
                %>.

Now I'm trying to convert the above iteration using the iterate tag of
struts, what I've done is this 

        <%
                try {
                        sai.db.IRecordIterator it =
invoiceService.getStatusSummary();
            pageContext.setAttribute("it", it, PageContext.PAGE_SCOPE);
                        while (it.next()!=null) {
                                aig.its.db.RecordInvoice rec =
(aig.its.db.RecordInvoice) it.current();
                pageContext.setAttribute("rec", rec,
PageContext.PAGE_SCOPE);
                
            %>
<logic:iterate id="item" name="it" property="rec">
       <tr bgcolor="<%=swapColor[currentSwapColor]%>">
        <td align="left">
         <bean:write name="rec" property="getGroupCount ()" filter="true"/>
        </td>
        <td align="left">
         <bean:write name="rec" property="getGroupSum
(aig.its.db.Tables.Invoice.InvoiceTotal)" filter="true"/>
        </td>        
       </tr>
</logic:iterate>

        <%

        if (currentSwapColor==0) currentSwapColor=1; else
currentSwapColor=0;
                        }
                }
                catch (java.sql.SQLException E) {
                        %><%=E.toString()%><%
                }
                %>        
.

        I'm getting the exception 
        javax.servlet.ServletException: No getter method for property rec of
bean it.

I have no idea where I'm going wrong, but I would appreciate if you could
help me sort this problem out.

Another problem that I'm facing is to convert the following to a struts
equivalent command, here I guess the jsp is called based on the multiple
params passed to it, I couldn't find anything similar in struts. Please
help.
<td class="ft"><a
href="invoice/list.jsp?numFields=1&wo0=eq&wf0=InvoiceStatus&wv0=<%=rec.getIn
voiceStatus()%>"><%=rec.getInvoiceStatusDescription ()%></a></td>

B Rgds
Raghu



-----Original Message-----
From: Ted Husted [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 23, 2001 4:42 PM
To: [EMAIL PROTECTED]
Subject: Re: Hot to get the iterated objects ?


The Struts tags often throw exceptions, but I don't believe any write to
a log. They do record the Exception in the request context though, so it
can be reported elsewhere (e.g. an JSP error page). Here's an example
from interate:

        else {
            JspException e = new JspException
                (messages.getMessage("iterate.iterator"));
            RequestUtils.saveException(pageContext, e);
            throw e;
        }

The messages for the exceptions are in <
taglib\logic\LocalStrings.properties >.

Sorry I could help with committing the indexed tag, but I haven't had a
chance to use it myself.


[EMAIL PROTECTED] wrote:
> 
> Hi Hal,
> 
> Oleg has siad he will incorporate the tag changes - just mailed him to
inquire
> when he thinks this will take place (I'm on vacation for 2 weeks from this
> Friday).
> 
> Am very happy to insert an exception - wasn't sure how the rest of Struts
tags
> handle this type of situation.
> 
> Does anyone else have a problem with throwing exception, rather than just
> writing to log?
> 
> Cheers,
> 
> Dave
> 
> "Deadman, Hal" <[EMAIL PROTECTED]> on
07/23/2001
> 01:14:00 PM
> 
> Please respond to [EMAIL PROTECTED]
> 
> To:   "'Struts Dev List'"
<[EMAIL PROTECTED]>
> cc:    (bcc: David Hay/Lex/Lexmark)
> Subject:  RE: Hot to get the iterated objects ?
> 
> I am looking forward to the seeing indexed tags in the nightly build. Has
a
> commiter signed up to incorporate the indexed tag changes?
> 
> As for feedback on the code, I don't think it's appropriate to blow off
the
> whole tag without comment if the tag with indexed="true" is not nested in
an
> iterate tag. I think an exception should be thrown instead. If an
exception
> isn't thrown then something needs to be written to the log file.
> 
> change:
>       IterateTag iterateTag = (IterateTag) findAncestorWithClass(this,
> IterateTag.class);
>       if (iterateTag == null)
>       {
>          // this tag should only be nested in iteratetag, if it's not,
don't
> do anything
>          return EVAL_PAGE;
>       }
> 
> to:
>       IterateTag iterateTag = (IterateTag) findAncestorWithClass(this,
> IterateTag.class);
>       if (iterateTag == null)
>       {
>          // this tag must only be nested in an IterateTag when indexed
> attribute is "true"
>         throw new JspException(messages.getMessage("some.messagekey");
>       }

winmail.dat

Reply via email to