hi nino,
i use something like that to download dynamically generated excel-files.
to get a resourcestream, i use this class:
---
package wicket.util;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.time.Time;
public class ByteArrayResourceStream
implements IResourceStream
{
private static final long serialVersionUID = 1L;
private Locale locale = null;
private byte[] content = null;
private String contentType = null;
public ByteArrayResourceStream( byte[] content, String contentType )
{
this.content = content;
this.contentType = contentType;
}
public void close( )
throws IOException
{
}
public String getContentType( )
{
return(contentType);
}
public InputStream getInputStream( )
throws ResourceStreamNotFoundException
{
return(new ByteArrayInputStream( content ));
}
public Locale getLocale( )
{
return(locale);
}
public long length( )
{
return(content.length);
}
public void setLocale( Locale locale )
{
this.locale = locale;
}
public Time lastModifiedTime( )
{
return null;
}
}
--8<---
then i just implement a link to my resource:
---8<---
public class XlsLink
extends Link
{
private static final long serialVersionUID = 1L;
byte[] xls = null;
public XlsLink( String id, byte[] xls )
{
super( id );
this.xls = xls;
}
public void onClick( )
{
IResourceStream resourceStream = new ByteArrayResourceStream( xls,
"application/vnd.ms-excel" );
getRequestCycle().setRequestTarget( new ResourceStreamRequestTarget(
resourceStream )
{
public String getFileName( )
{
return("export.xls");
}
} );
}
}
---8<--
that's all about it.
best regards, --- jan.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]