@SetupRender problème + affichage d'un tableau
Bonjour tout le monde,
je suis entrain de développer une application sur tapestry, et j'ai rencontre qq problemes :?
bref j'ai développé un service qui exporte des 'sales' depuis ma database selon des critères, dans ma couche présentation (view) je veux afficher mes 'sales' dans un tableau et en même temps les exporter dans un fichier excel,
mais a chaque fois le serveur me rend une erreur de 'SteupRender' en plus mon tableau ne s'affiche pas dans ma page.
voila ma page:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
<html
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
<head>
<title>TESTING</title>
</head>
<body>
<div class="sale-expo" >
<t:form t:id="ExportSalesFrom" t:type="form">
<t:beaneditor object="saleSearchCriterion">
<t:parameter name="dtcreationFrom">
<t:label for="dtcreationFrom">Created From</t:label>
<t:datefield t:id="dtcreationFrom" value="saleSearchCriterion.dtCreationFrom"/>
</t:parameter>
<t:parameter name="dtcreationTo">
<t:label for="dtcreationTo">To</t:label>
<t:datefield t:id="dtcreationTo" value="saleSearchCriterion.dtCreationTo"/>
</t:parameter>
<t:parameter name="activity">
<t:label for="activity">Activity</t:label>
<t:select t:id="activity" value="saleSearchCriterion.activity" model="${actModel}"
blankOption="AUTO" blankLabel="All"/>
</t:parameter>
</t:beaneditor>
<input t:id="search" t:type="submit" value="search"/>
</t:form>
<t:if test="listExist">
<div class="sale-expo-result">
<a t:type="actionlink" t:id="exportSalesToExcel"><img src="${excelExportSales}" alt="export to Excel"
width="20"> </img></a>
<div>
<table t:type="grid" t:source="sales" t:rowsPerPage="5"></table>
</div>
</div>
</t:if>
</div>
</body>
</html> |
et voila ma classe java:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| package com.citrusstv.core.pages.domain;
import com.project.core.domain.entities.Activity;
import com.project.core.domain.entities.Sale;
import com.project.core.domain.export.ExportType;
import com.project.core.domain.services.SaleSearchCriterion;
import com.project.core.domain.services.SaleService;
import com.project.core.utils.ExcelStreamResponse;
import org.apache.tapestry5.Asset;
import org.apache.tapestry5.SelectModel;
import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.SelectModelFactory;
import org.slf4j.Logger;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Import(stylesheet = "context:layout/pages/sales.css")
public class SalesExpo {
@Inject
private Logger log;
@Inject
private SaleService saleservice;
@Inject
private SelectModelFactory selectModelFactory;
@Inject
@Path("context:layout/images/export/excel-export.jpg")
private Asset excelExportSales;
@SessionState
private SaleSearchCriterion _saleSearchCriterion;
@Property
private Sale curSale;
@Property
private SelectModel actModel;
@Property
private List<Sale> _sales;
public SaleSearchCriterion getSaleSearchCriterion() {
return _saleSearchCriterion;
}
public boolean isListExist(){
return (_sales!=null && _sales.size()>0)?true:false;
}
/**
*
public List<Sale> getSales() {
return _sales;
}
*
*/
public Asset getExcelExportSales() {
return excelExportSales;
}
public void onActivate() {
//initializeValue();
System.out.println("Default on Activate Method *********************** ");
log.info("on Load");
}
@SetupRender
public void initialize()
{
actModel = selectModelFactory.create(Activity.findAll(), "description");
}
//@AfterRender
public void onActionFromsearch(){
//System.out.println("******************************* BEGIN onActionFromsearch *********************** ");
List<Sale> saleList = saleservice.findSales(_saleSearchCriterion);
log.info(saleList.size()+"sale was found");
_sales = saleList;
//System.out.println("******************************* END onActionFromsearch *********************** ");
}
public StreamResponse onActionFromExportSalesToExcel()
{
log.debug("try Exporting");
return new ExcelStreamResponse()
{
@Override
protected String performExport(ByteArrayOutputStream outputStream) {
try {
saleservice.exportSales(ExportType.Excel, _saleSearchCriterion, outputStream);
return "sales-export-" + System.currentTimeMillis();
} catch (IOException e) {
log.error(e.getMessage(), e);
throw new RuntimeException("Cannot generate file");
}
}
};
}
} |