Hack Alert:
public String exportCSV() throws Exception {
// Search based upon the entered criteria
// TODO: pass the previously found List in, instead of
performing the locate again
// Use the Criteria, create a list of transactionBeans, and
return it
UserBean user = (UserBean) super.getLoginUser();
this.transList = transService.locate(transaction, user);
// This is Kludgey for Struts 2. Rework the proper way when you
get a chance...
HttpServletResponse response = ServletActionContext.getResponse();
if (this.transList != null)
{
// Now...Let's Export the son of a gun
if (logger.isDebugEnabled())
{
logger.debug("Exporting Tables to Disk... ");
}
ServletOutputStream out = response.getOutputStream();
//
---------------------------------------------------------------
// Set the output data's mime type
//
---------------------------------------------------------------
response.setContentType("application/text");
response.setHeader("Content-disposition",
"filename=\"Transactions.csv\"");
out.println("Tracking #,Ext Auth #,Debtor Name");
Iterator iter = transList.iterator();
while (iter.hasNext())
{
TransactionBean trans = (TransactionBean)iter.next();
out.println(trans.getTrackingNumber() + "," +
trans.getVendorTrackingNumber() + "," +
trans.getDebtorName());
}
out.flush();
out.close();
return null;
}
else
{
addActionError("No results were returned based upon the
search criteria supplied.");
return "locsearch-error";
}
}
newton.dave wrote:
--- Musachy Barroso <[EMAIL PROTECTED]
<http://www.nabble.com/user/SendEmail.jtp?type=post&post=11198867&i=0>>
wrote:
> Or you can write your own result, and generate the
> CSV file there (reusable, clean, bla bla)
I did that, to a very small degree (not to the extent
of JSONResult; I'm lazy) but haven't gotten around to
cleaning it up yet--it's pretty hacky.
Someone should go ahead and write a real version :D
It seemed a bit much for the current question under
discussion, I thought :)
d.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]