example:

I have an ExcelScreen base class.

public class ExcelScreen extends VelocityScreen 
{
    // not exactly a CSV, but works for MS Windows clients with excel installed
    // excel will open tables directly as spreadsheet fields... can save as csv easily 
from there

    private static String CONTENT_TYPE = "application/vnd.ms-excel";
    private static String DEFAULT_LAYOUT = "VelocityOnlyLayout";
    private static String DEFAULT_LAYOUT_VM = "/ExcelDataLayout.vm";
                                                                                       
                                                        
    public void doBuildTemplate(RunData data, Context context) 
    {
        try 
        {
            String filename = data.getParameters().getString("filename");
            if ( filename != null ) { 
                filename.trim();
            } 
            else {
                filename = "export.xls";
            }

            data.setLayoutTemplate(DEFAULT_LAYOUT_VM);
            data.setContentType(CONTENT_TYPE);
                                                                                       
                                                        
            HttpServletResponse resp = data.getResponse();
            resp.setHeader("Content-Type", CONTENT_TYPE);
            resp.setHeader("Content-Disposition", "inline; filename=" + filename );
        } 
        catch (Exception e) {
            Log.error("ExcelScreen error: " + e.toString());
        }
    }
}                                                                                      
                                                         


On Tue, 24 Aug 2004, Vjeran Marcinko wrote:

> Hi folks.
> 
> Is there some way to mark certain pages to be of some other HTTP
> "ContentType" than text/html as rest of application ?
> Let's say that my Turbine app should have some templates that generate web
> pages, some wap pages, some VoiceXML content, etc....
> Is it possible, or should I create some base class where I should put
> response.setContentType(...), and all non-html screens should extend that ?
> 
>  Cheers,
> Vjeran
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to