You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by jose luis sanchez <jo...@m-centric.com> on 2009/09/17 10:26:26 UTC

StreamResponse on Success

Hi all.
I've found myself a problem in an application i've developed using T5.1

There's a page, with 2 datefields, ( From / To ), and a Submit.

The Submit button calls the  StreamResponse onSuccess() method  , 
returning a CVS file with a list of records.

But i'd like to show a label with the total records output, but it looks 
likes there's no page refresh , so the total value is not updated.

Any help on this ?

Thanks.

/*** tml ***/

 <t:form t:id="exportCDRForm">
     <t:errors/>
                <table>
                    <tr>
                        <td><t:label for="fromDate"/></td>
                        <td><t:datefield t:id="fromDate" 
format="dd/MM/yyyy"/></td>
                    </tr>
                    <tr>
                        <td><t:label for="toDate"/></td>
                        <td><t:datefield t:id="toDate" 
format="dd/MM/yyyy"/></td>
                    </tr>
                    <tr>
                        <td colspan="2" align="right"><t:submit 
t:id="createbutton" value="export"/></td>
                    </tr>
                </table>
        <t:if test="total">
            <hr/>
            <div align="center"><h2>You have exported ${total} 
transactions</h2></div>
            <br/>
        </t:if>
             </t:form>


/**** java ****/
@Property
private int total;

StreamResponse onSuccess() {

        List <HSITransaction> transactionList = 
theSession.createCriteria(HSITransaction.class)
        .add(Restrictions.ge("transactionDate", fromDate))
        .add(Restrictions.le("transactionDate", toDate))
        .list();
        total = transactionList.size();
        if (total > 0) {
            try {
                return exportCSV(transactionList);
            } catch (Exception e) {
                theForm.recordError("Sorry, there was an error exporting 
CDR's :"+e.getMessage());
            }
        } else theForm.recordError("Sorry, there was no data to export");
        return null;

    }



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org