Sure (and thanks as usual Taha!) so I have a wrapper around a grid and the
csv export. I simplified the code quite a bit so hopefully its easy to
understand.

page tml:
       <t:myGrid source="data" inPlace="true"/>
in myGrid.tml
   <t:form>
      <t:grid t:id="grid"/>
      <t:if test="${exportCsv}">
         <t:csvExporter t:id="csvExporter"/>
      </t:if>
      <t:block id="empty">Move along, nothing to see.</t:block>
  </t:form>              

in MyGrid.java
@Component
private CsvExporter csvExporter(parameters={"hasData=hasData"});

@Component(publishParameters = "add, class, columnIndex,, encoder, empty,
exclude, inPlace, include, lean, model, overrides, reorder, row, rowClass,
rowIndex, sortModel, volatile",
           parameters = {"pagerPosition=prop:pagerPosition",
"rowsPerPage=rowsPerPage", "source=prop:source"})
private Grid grid;

@Property
private GridDataSource source;

public boolean isHasData()
{return this.source.getAvailableRows() > 0;}

//form submit event handler   
@OnEvent(value="submit")
Object runExport() throws Exception
{
  //example of grid state I am using to generate the csv -- ie, csv is
generated in order that user sortted the grid. if I do not do this, the csv
source is in its unsorted original unsorted state
  this.source.prepare(0, this.source.getAvailableRows(),
this.grid.getSortModel().getSortConstraints());
  ByteArrayOutputStream baos = getCsv(this.source,
this.csvExporter.getMonthSel()); //gets csv data and filters only data for a
month
  return new ExportStreamResponse(baos); //just a simple implementation of
StreamResponse
}     

CsvExporter.tml
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
   <t:if test="${hasData}">
      <div>
         <ul>
            <t:loop source="1..12" value="month">
               <li>
                  
                      
                        ${exportFormatMsg}
                      
                                   
               </li>
            </t:loop>
         </ul>
      </div>
   </t:if>  
</t:container>

CsvExporter.java

@Parameter(required = true)
@Property
private boolean hasData();

@Property
private int month;

private int monthSel;
public int getMonthSel()
{return this.monthSel;}

@SuppressWarnings("unused")
@Component(parameters = {"event=clicky", "context=monthSel", "defer=false"})
private LinkSubmit csvLink;

@OnEvent(value = "clicky")
void linkExport(int month)
{
  this.monthSel = month;
}



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/StreamResponse-and-inPlace-Grid-question-tp4760076p4762779.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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

Reply via email to