RSSFeedBehavior(String url) {
this.url = url;
}
public void onRequest() {
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(new AbstractResourceStream() {
private static final long serialVersionUID = -322593118428697261L;
HttpURLConnection con;
public InputStream getInputStream() throws ResourceStreamNotFoundException {
try {
con = getFeedConnection(url);
con.connect();
return con.getInputStream();
} catch (IOException e) {
throw new ResourceStreamNotFoundException();
}
}
public void close() throws IOException {
if (con != null) {
con.disconnect();
}
}
}, "feed");
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}