Looks like a bug. I think StringResourceStream has to initialize its lastModifiedTime in the constructor to Time.now().
I'll create a ticket and fix it. On Tue, Nov 23, 2010 at 8:05 PM, jcgarciam <jcgarc...@gmail.com> wrote: > > Hi Folks, > > Probably im doing it wrong, but please bear with me, currently i'm trying > to > do a very simple download operation in wicket 1.5M3, but it fails with a > NPE > in (ResourceStreamResource.java line 72), because it seems is always > expecting that any IResourceStream implementation set the lastModifiedTime > in the underlying stream before calling dataNeedsToBeWritten which > StringResourceStream doesn't do it ( i need to explicitly set it to make it > work ) . > > @Override > protected ResourceResponse newResourceResponse(Attributes > attributes) > { > ResourceResponse data = new ResourceResponse(); > (72)-> data.setLastModified(stream.lastModifiedTime().toDate()); > > > My code using [StringResourceStream] > <code> > final StringBuilder content = new StringBuilder("Hello,world"); > add(new Link<Void>("downloadDoc") { > @Override > public void onClick() { > StringResourceStream stream = new > StringResourceStream(content.toString(),"html/csv"); > > getRequestCycle().scheduleRequestHandlerAfterCurrent(new > ResourceStreamRequestHandler(stream) > .setFileName("demo.csv") > > .setContentDisposition(ContentDisposition.ATTACHMENT)); > } > }); > </code> > > Calling [stream.setLastModified(Time.now());] right before scheduling the > request handler make the download to works, but it seems that probably im > doing something wrong (not supposed to a download on this way) or does it > sounds like a bug in [ResourceStreamResource.java]? > > Thanks, > > Attached is a quickstart > > http://apache-wicket.1842946.n4.nabble.com/file/n3056036/DownloadStreamBug.7z > DownloadStreamBug.7z > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Simple-Download-from-StringResourceStream-cause-NPE-wicket-1-5M3-possible-bug-tp3056036p3056036.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >