You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Maxim Solodovnik <so...@gmail.com> on 2017/04/12 09:07:07 UTC

Re: Question regarding new AjaxDownload (WICKET-6286)

Hello All,

I have updated my project
https://github.com/solomax/ajax-download/commit/453663a55f390e54354381ab0f009d194e37e87c
To set filename
But file being downloaded has random UUID as file name, what am I doing
wrong?

On Wed, Mar 29, 2017 at 9:31 PM, Maxim Solodovnik <so...@gmail.com>
wrote:

> Will try to migrate all my use cases on a SNAPSHOT first
> Then will do
> Thanks Martin!
>
> On Wed, Mar 29, 2017 at 9:28 PM, Martin Grigorov <mg...@apache.org>
> wrote:
> > Maxim, you can use Location.IFrame or Location.SameWindow too in -M5 (to
> be
> > released!).
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Wed, Mar 29, 2017 at 4:26 PM, Sven Meier <sv...@meiers.net> wrote:
> >
> >> In a minute :P
> >>
> >> Sven
> >>
> >>
> >>
> >> On 29.03.2017 16:15, Andrea Del Bene wrote:
> >>
> >>> Right when we will return to "success" :-)
> >>>
> >>> https://ci.apache.org/builders/wicket-master
> >>>
> >>> On Wed, Mar 29, 2017 at 4:07 PM, Maxim Solodovnik <
> solomax666@gmail.com>
> >>> wrote:
> >>>
> >>> Wow, Thanks a lot!
> >>>> Could you please let me know when SNAPSHOT with the fix will be
> >>>> available?
> >>>>
> >>>> On Wed, Mar 29, 2017 at 8:50 PM, Sven Meier <sv...@meiers.net> wrote:
> >>>>
> >>>>> Hi,
> >>>>>
> >>>>> so we have to change the Location.Blob to use XMLHttpRequest
> directly,
> >>>>> because jQuery does not support blob downloads :/.
> >>>>>
> >>>>> I've change the JavaScript and now downloading of the zip works fine.
> >>>>>
> >>>>> FileSystemResource might not be the best candidate (because it's not
> >>>>> serializable), but you can use an indirection to prevent it being
> >>>>>
> >>>> serialized
> >>>>
> >>>>> along with AjaxDownload:
> >>>>>
> >>>>>          final AjaxDownload download = new AjaxDownload(
> >>>>>              new IResource()
> >>>>>              {
> >>>>>                  @Override
> >>>>>                  public void respond(Attributes attributes)
> >>>>>                  {
> >>>>>                      new
> >>>>> FileSystemResource(zipFile.toPath()).respond(attributes);
> >>>>>                  }
> >>>>>              }
> >>>>>          );
> >>>>>
> >>>>> Have fun
> >>>>> Sven
> >>>>>
> >>>>>
> >>>>>
> >>>>> On 29.03.2017 15:12, Maxim Solodovnik wrote:
> >>>>>
> >>>>>> Filename is minor issue ....
> >>>>>> Main problem is invalid file :(
> >>>>>>
> >>>>>> How can I serve the file from file system? I thought
> >>>>>> filesystemreference
> >>>>>> if
> >>>>>> the best candidate .....
> >>>>>>
> >>>>>> WBR, Maxim
> >>>>>> (from mobile, sorry for the typos)
> >>>>>>
> >>>>>> On Mar 29, 2017 8:08 PM, "Sven Meier" <sv...@meiers.net> wrote:
> >>>>>>
> >>>>>> Hi Maxim,
> >>>>>>>
> >>>>>>> three things:
> >>>>>>>
> >>>>>>> - filename ... no one sets the file name :P
> >>>>>>>
> >>>>>>> - serializable error ... FileSystemResource holds a reference to
> the
> >>>>>>> path,
> >>>>>>> which is not serializable
> >>>>>>>
> >>>>>>> - corruct zip ... my bad, it seems that Location.Blob mangles the
> file
> >>>>>>>
> >>>>>> on
> >>>>
> >>>>> the client side
> >>>>>>>
> >>>>>>> I'll see what I can do about Location.Blob - it might be an
> encoding
> >>>>>>> issue.
> >>>>>>>
> >>>>>>> Have fun
> >>>>>>> Sven
> >>>>>>>
> >>>>>>>
> >>>>>>> On 29.03.2017 14:15, Maxim Solodovnik wrote:
> >>>>>>>
> >>>>>>> here you are: https://github.com/solomax/ajax-download
> >>>>>>>> Absolutely don't understand what is going on :(
> >>>>>>>>
> >>>>>>>> On Wed, Mar 29, 2017 at 6:30 PM, Maxim Solodovnik <
> >>>>>>>>
> >>>>>>> solomax666@gmail.com>
> >>>>
> >>>>> wrote:
> >>>>>>>>
> >>>>>>>> Yep, zip file is valid
> >>>>>>>>> Breakpoint at AjaxDownload.ResourceBehavior#onRequest() is not
> hit
> >>>>>>>>>
> >>>>>>>> :(
> >>>>
> >>>>> Will try to create quickstart
> >>>>>>>>>
> >>>>>>>>> something extremely weird
> >>>>>>>>>
> >>>>>>>>> On Wed, Mar 29, 2017 at 2:22 AM, Martin Grigorov <
> >>>>>>>>>
> >>>>>>>> mgrigorov@apache.org>
> >>>>
> >>>>> wrote:
> >>>>>>>>>
> >>>>>>>>> Hi Maxim,
> >>>>>>>>>>
> >>>>>>>>>> On Tue, Mar 28, 2017 at 11:06 AM, Maxim Solodovnik <
> >>>>>>>>>> solomax666@gmail.com>
> >>>>>>>>>> wrote:
> >>>>>>>>>>
> >>>>>>>>>> Thanks a lot Martin for detailed explanation
> >>>>>>>>>>
> >>>>>>>>>>> I do have this functionality working with old version of
> >>>>>>>>>>>
> >>>>>>>>>> AjaxDownload
> >>>>
> >>>>> And here is my first try to migrate to the new internal wicket
> >>>>>>>>>>> AjaxDownload:
> >>>>>>>>>>> https://github.com/apache/openmeetings/commit/
> >>>>>>>>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f
> >>>>>>>>>>>
> >>>>>>>>>>> I would appreciate if you can take a look at this tiny commit.
> >>>>>>>>>>>
> >>>>>>>>>>> Something really doesn't work as expected ....
> >>>>>>>>>>>
> >>>>>>>>>>> Commited version behaves wrong:
> >>>>>>>>>>> 1) file downloaded has wrong name
> >>>>>>>>>>>
> >>>>>>>>>>> You do not set file name anywhere!
> >>>>>>>>>>>
> >>>>>>>>>> Keep a reference to the constructed ResourceResponse and call
> its
> >>>>>>>>>> #setFileName(...)
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> 2) is not valid zip file (cannot be opened)
> >>>>>>>>>>
> >>>>>>>>>>> Is the backupPath representing a ZIP file ?
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> 3) for some reason I'm not able to get to breakpoint at line 115
> >>>>>>>>>> [1]
> >>>>>>>>>>
> >>>>>>>>>>> Put a breakpoint at
> >>>>>>>>>>> AjaxDownload.ResourceBehavior#onResourceRequested()
> >>>>>>>>>>>
> >>>>>>>>>> and
> >>>>>>>>>> see what happens
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Additionally I got NotSerializable exception in case I made
> >>>>>>>>>>
> >>>>>>>>> "download"
> >>>>
> >>>>> class final variable
> >>>>>>>>>>>
> >>>>>>>>>>> java.nio.file.Path is not Serializable!
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> What am I doing wrong?
> >>>>>>>>>>
> >>>>>>>>>>> [1] https://github.com/apache/openmeetings/commit/
> >>>>>>>>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f#diff-
> >>>>>>>>>>> 0a499c88998a93ceb51c347836aa6195R115
> >>>>>>>>>>>
> >>>>>>>>>>> On Thu, Mar 23, 2017 at 3:16 AM, Martin Grigorov
> >>>>>>>>>>> <mgrigorov@apache.org
> >>>>>>>>>>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>> On Wed, Mar 22, 2017 at 12:59 PM, Maxim Solodovnik <
> >>>>>>>>>>>> solomax666@gmail.com
> >>>>>>>>>>>>
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>> Actually I have 2 example use cases:
> >>>>>>>>>>>>
> >>>>>>>>>>>>> 1) user selects files on file tree
> >>>>>>>>>>>>> 2) as soon as file is selected and download is enabled for
> it,
> >>>>>>>>>>>>>
> >>>>>>>>>>>> used
> >>>>
> >>>>> can
> >>>>>>>>>>>>> press ajax download button and get the file
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Another case:
> >>>>>>>>>>>>> User requests system backup
> >>>>>>>>>>>>> As soon as backup is created (Progress complete)
> >>>>>>>>>>>>> Download of newly created file should be initiated
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> I can't create ResourceReference and override
> getResourceStream
> >>>>>>>>>>>>>
> >>>>>>>>>>>> of
> >>>>
> >>>>> it
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> since
> >>>>>>>>>>>> I only have resource just before download
> >>>>>>>>>>>>
> >>>>>>>>>>>>> Wicket IResource is an abstraction over the real resource.
> >>>>>>>>>>>>>
> >>>>>>>>>>>> In my case i also create the response on the fly. It is
> either a
> >>>>>>>>>>>> single
> >>>>>>>>>>>> File or a Zip file with several entries.
> >>>>>>>>>>>> The ResourceReference is more or less just an endpoint with
> >>>>>>>>>>>> almost
> >>>>>>>>>>>> no
> >>>>>>>>>>>>
> >>>>>>>>>>>> logic
> >>>>>>>>>>>
> >>>>>>>>>>> at all. It just creates the IResource.
> >>>>>>>>>>>> The IResource uses the information from the request
> parameters /
> >>>>>>>>>>>> session
> >>>>>>>>>>>>
> >>>>>>>>>>>> /
> >>>>>>>>>>>
> >>>>>>>>>>> somewhere else to create the actual response (the files).
> >>>>>>>>>>>>
> >>>>>>>>>>>> AjaxDownload is an Ajax behavior that you can use to trigger
> the
> >>>>>>>>>>>> creation
> >>>>>>>>>>>> of the files and by using its callback methods you can show
> >>>>>>>>>>>>
> >>>>>>>>>>> feedback
> >>>>
> >>>>> to
> >>>>>>>>>>>>
> >>>>>>>>>>>> the
> >>>>>>>>>>>
> >>>>>>>>>>> user. To show progress bar you will need to employ ProgressBar
> >>>>>>>>>>>>
> >>>>>>>>>>> from
> >>>>
> >>>>> wicket-extentions or use WebSockets.
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> On Wed, Mar 22, 2017 at 6:53 PM, Martin Grigorov <
> >>>>>>>>>>>>
> >>>>>>>>>>>>> mgrigorov@apache.org>
> >>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Hi Maxim,
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> I use the new AjaxDownload with a ResourceReference, i.e.
> >>>>>>>>>>>>>> AjaxDownload#AjaxDownload(org.apache.wicket.request.
> >>>>>>>>>>>>>> resource.ResourceReference,
> >>>>>>>>>>>>>> org.apache.wicket.request.mapper.parameter.PageParameters)
> >>>>>>>>>>>>>> The ResourceReference has
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> public IResource getResource() {
> >>>>>>>>>>>>>>        return new StatementDownloadResource();
> >>>>>>>>>>>>>> }
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> StatementDownloadResource extends ResourceStreamResource and
> >>>>>>>>>>>>>> provides
> >>>>>>>>>>>>>> implementation of #getResourceStream(). There I have a logic
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> that
> >>>>
> >>>>> returns
> >>>>>>>>>>>>>
> >>>>>>>>>>>> either FileResourceStream or ZipResourceStream.
> >>>>>>>>>>>>
> >>>>>>>>>>>>> Martin Grigorov
> >>>>>>>>>>>>>> Wicket Training and Consulting
> >>>>>>>>>>>>>> https://twitter.com/mtgrigorov
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> On Wed, Mar 22, 2017 at 12:30 PM, Maxim Solodovnik <
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> solomax666@gmail.com
> >>>>>>>>>>>>>
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>>> Just have tried to switch to this AjaxDownload component
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> And it seems I cannot find proper way to use it with
> dynamic
> >>>>>>>>>>>>>>> file,
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> i.e.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> previously
> >>>>>>>>>>>>
> >>>>>>>>>>>>> I created AjaxDownload,
> >>>>>>>>>>>>>>> added it to the page
> >>>>>>>>>>>>>>> then at the moment I know what file should be served, I set
> >>>>>>>>>>>>>>> the
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> stream
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> and
> >>>>>>>>>>>>
> >>>>>>>>>>>>> initiate the download
> >>>>>>>>>>>>>>> (for example one of use cases: I need to create zip file
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> right now this seems to be impossible :(
> >>>>>>>>>>>>>>> Can you give me a hint how this dynamic nature can be
> >>>>>>>>>>>>>>> implemented?
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> --
> >>>>>>>>>>>>>>> WBR
> >>>>>>>>>>>>>>> Maxim aka solomax
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> --
> >>>>>>>>>>>>> WBR
> >>>>>>>>>>>>> Maxim aka solomax
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> --
> >>>>>>>>>>> WBR
> >>>>>>>>>>> Maxim aka solomax
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> --
> >>>>>>>>> WBR
> >>>>>>>>> Maxim aka solomax
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>
> >>>> --
> >>>> WBR
> >>>> Maxim aka solomax
> >>>>
> >>>>
> >>
>
>
>
> --
> WBR
> Maxim aka solomax
>



-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
Clear browser cache did the job
After browser cache clear and setting Duration.NONE everything seems to work

Thanks a lot!
Will try to do some more tests, then ask our users to also test

On Thu, Apr 13, 2017 at 5:10 PM, Sven Meier <sv...@meiers.net> wrote:

> Works fine here.
>
> Note that you have to clear your browser cache, otherwise you'll still get
> the downloaded files without "attachment" in the header.
>
> It would probably be a good idea, to disable caching on your resource:
>
>        response.setCacheDuration(Duration.NONE);
>
> Have fun
> Sven
>
>
>
> On 13.04.2017 03:15, Maxim Solodovnik wrote:
>
>> I have modified my quickstart https://github.com/solomax/ajax-download
>>
>> disposition set to ATTACHMENT
>>
>> problems so far:
>> 1) only one AjaxDownload on the page works (example:
>> https://github.com/solomax/ajax-download/commit/ed5c8f898318
>> da9933369c4bc5ecb5f12fb046c1
>> )
>> 2) setting file name has no effect: for whatever reason file being
>> downloaded has random UUID name for blob and "download" for iframe, and
>> "zip" as extension
>>
>> Quickstart now contains 4 buttons, each generates different "dynamic"
>> content
>> Please check
>>
>> On Thu, Apr 13, 2017 at 4:17 AM, Sven Meier <sv...@meiers.net> wrote:
>>
>> Hi Martin,
>>>
>>> actually I meant that FileSystemResource could have a way to *configure*
>>> the content disposition.
>>>
>>> There seems to be some duplication emerging between FileSystemResource
>>> and
>>> ResourceStreamResource now.
>>>
>>> Regards
>>>
>>> Sven
>>>
>>>
>>>
>>> On 12.04.2017 22:33, Martin Grigorov wrote:
>>>
>>> Hi Sven,
>>>>
>>>> This is another thing that could be added to FileSystemResource besides
>>>> the file name.
>>>>
>>>> Why do you think it is safe to assume that ATTACHMENT should be set ?
>>>> I see
>>>> that org.apache.wicket.request.resource.BaseDataResource#newResou
>>>> rceResponse()
>>>> does this.
>>>> But org.apache.wicket.request.resource.ContextRelativeResource#n
>>>> ewResourceResponse()
>>>> and org.apache.wicket.request.resource.ResourceStreamResource#ne
>>>> wResourceResponse()
>>>> set the filename without setting the content disposition.
>>>> org.apache.wicket.request.resource.AbstractResource.Resource
>>>> Response#contentDisposition
>>>> is INLINE by default.
>>>>
>>>> I'll improve the javadoc of AjaxDownload that the content disposition
>>>> should be set manually by the application and that INLINE could be used
>>>> only with Location.NewWindow
>>>>
>>>>
>>>> Martin Grigorov
>>>> Wicket Training and Consulting
>>>> https://twitter.com/mtgrigorov
>>>>
>>>> On Wed, Apr 12, 2017 at 3:09 PM, Sven Meier <sv...@meiers.net> wrote:
>>>>
>>>> Hi Maxim,
>>>>
>>>>> the resource is responsible to set the right content disposition.
>>>>>
>>>>> This is another thing that could be added to FileSystemResource besides
>>>>> the file name.
>>>>>
>>>>> Have fun
>>>>> Sven
>>>>>
>>>>>
>>>>>
>>>>> On 12.04.2017 14:39, Maxim Solodovnik wrote:
>>>>>
>>>>> I thought Attachment is set by default since it is download ....
>>>>>
>>>>>> Should I retest with it?
>>>>>>
>>>>>> Can invalid file name be caused by wrong disposition type?
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> you have to set the content disposition too:
>>>>>>>
>>>>>>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>>>>>>
>>>>>>> We could improve the JavaScript so it is more lenient and works
>>>>>>> without
>>>>>>> "attachment" in the header.
>>>>>>>
>>>>>>> Have fun
>>>>>>> Sven
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>>>>>>
>>>>>>> In case I'm setting Location as iFrame, file being downloaded is
>>>>>>>
>>>>>>> "download.zip"
>>>>>>>> The file name set is also has no effect
>>>>>>>>
>>>>>>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <
>>>>>>>> solomax666@gmail.com
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Weird enough
>>>>>>>>
>>>>>>>> I have changed the code to produce pain text file (And it is being
>>>>>>>>
>>>>>>>>> created
>>>>>>>>> and has valid text)
>>>>>>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>>>>>>> like it was cached somewhere in the browser
>>>>>>>>>
>>>>>>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Then, set the content type to text/html so see if the filename is
>>>>>>>>> correct
>>>>>>>>>
>>>>>>>>> in that case.
>>>>>>>>>
>>>>>>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>>>>>>> solomax666@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> In case I'm setting file name to "backp.zip.html" the file is
>>>>>>>>>> being
>>>>>>>>>>
>>>>>>>>>> downloaded as <UUID>.zip
>>>>>>>>>>
>>>>>>>>>>> I guess "zip" is being set from content type
>>>>>>>>>>> File name is just ignored
>>>>>>>>>>>
>>>>>>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>> I know, it's just to test the filename...
>>>>>>>>>>>
>>>>>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>>>>>
>>>>>>>>>>>> solomax666@gmail.com
>>>>>>>>>>>>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>>>>>
>>>>>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>>>>>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> I did the same problem recently (I still have to answer Sven
>>>>>>>>>>>> about
>>>>>>>>>>>>
>>>>>>>>>>> this,
>>>>>>>>>>>
>>>>>>>>>>>> I
>>>>>>>>>>>>>
>>>>>>>>>>>>> will do it soon)
>>>>>>>>>>>>>
>>>>>>>>>>>>> Try out changing your extension to ".html" to see if it's the
>>>>>>>>>>>>>> same
>>>>>>>>>>>>>> behavior, maybe it will help you to investigate further. (in
>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> case,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> "csv"
>>>>>>>>>>>>>
>>>>>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> WBR
>>>>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>>
>>>>>>>>>>>>> WBR
>>>>>>>>>>>>
>>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> WBR
>>>>>>>>>>
>>>>>>>>> Maxim aka solomax
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>
>


-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sven Meier <sv...@meiers.net>.
Works fine here.

Note that you have to clear your browser cache, otherwise you'll still 
get the downloaded files without "attachment" in the header.

It would probably be a good idea, to disable caching on your resource:

        response.setCacheDuration(Duration.NONE);

Have fun
Sven


On 13.04.2017 03:15, Maxim Solodovnik wrote:
> I have modified my quickstart https://github.com/solomax/ajax-download
>
> disposition set to ATTACHMENT
>
> problems so far:
> 1) only one AjaxDownload on the page works (example:
> https://github.com/solomax/ajax-download/commit/ed5c8f898318da9933369c4bc5ecb5f12fb046c1
> )
> 2) setting file name has no effect: for whatever reason file being
> downloaded has random UUID name for blob and "download" for iframe, and
> "zip" as extension
>
> Quickstart now contains 4 buttons, each generates different "dynamic"
> content
> Please check
>
> On Thu, Apr 13, 2017 at 4:17 AM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi Martin,
>>
>> actually I meant that FileSystemResource could have a way to *configure*
>> the content disposition.
>>
>> There seems to be some duplication emerging between FileSystemResource and
>> ResourceStreamResource now.
>>
>> Regards
>>
>> Sven
>>
>>
>>
>> On 12.04.2017 22:33, Martin Grigorov wrote:
>>
>>> Hi Sven,
>>>
>>> This is another thing that could be added to FileSystemResource besides
>>> the file name.
>>>
>>> Why do you think it is safe to assume that ATTACHMENT should be set ?
>>> I see
>>> that org.apache.wicket.request.resource.BaseDataResource#newResou
>>> rceResponse()
>>> does this.
>>> But org.apache.wicket.request.resource.ContextRelativeResource#n
>>> ewResourceResponse()
>>> and org.apache.wicket.request.resource.ResourceStreamResource#ne
>>> wResourceResponse()
>>> set the filename without setting the content disposition.
>>> org.apache.wicket.request.resource.AbstractResource.Resource
>>> Response#contentDisposition
>>> is INLINE by default.
>>>
>>> I'll improve the javadoc of AjaxDownload that the content disposition
>>> should be set manually by the application and that INLINE could be used
>>> only with Location.NewWindow
>>>
>>>
>>> Martin Grigorov
>>> Wicket Training and Consulting
>>> https://twitter.com/mtgrigorov
>>>
>>> On Wed, Apr 12, 2017 at 3:09 PM, Sven Meier <sv...@meiers.net> wrote:
>>>
>>> Hi Maxim,
>>>> the resource is responsible to set the right content disposition.
>>>>
>>>> This is another thing that could be added to FileSystemResource besides
>>>> the file name.
>>>>
>>>> Have fun
>>>> Sven
>>>>
>>>>
>>>>
>>>> On 12.04.2017 14:39, Maxim Solodovnik wrote:
>>>>
>>>> I thought Attachment is set by default since it is download ....
>>>>> Should I retest with it?
>>>>>
>>>>> Can invalid file name be caused by wrong disposition type?
>>>>>
>>>>> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>>> you have to set the content disposition too:
>>>>>>
>>>>>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>>>>>
>>>>>> We could improve the JavaScript so it is more lenient and works without
>>>>>> "attachment" in the header.
>>>>>>
>>>>>> Have fun
>>>>>> Sven
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>>>>>
>>>>>> In case I'm setting Location as iFrame, file being downloaded is
>>>>>>
>>>>>>> "download.zip"
>>>>>>> The file name set is also has no effect
>>>>>>>
>>>>>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <
>>>>>>> solomax666@gmail.com
>>>>>>> wrote:
>>>>>>>
>>>>>>> Weird enough
>>>>>>>
>>>>>>> I have changed the code to produce pain text file (And it is being
>>>>>>>> created
>>>>>>>> and has valid text)
>>>>>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>>>>>> like it was cached somewhere in the browser
>>>>>>>>
>>>>>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>>>
>>>>>>>> Then, set the content type to text/html so see if the filename is
>>>>>>>> correct
>>>>>>>>
>>>>>>>> in that case.
>>>>>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>>>>>> solomax666@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>>>>>>
>>>>>>>>> downloaded as <UUID>.zip
>>>>>>>>>> I guess "zip" is being set from content type
>>>>>>>>>> File name is just ignored
>>>>>>>>>>
>>>>>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> I know, it's just to test the filename...
>>>>>>>>>>
>>>>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>>>>> solomax666@gmail.com
>>>>>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>>>> this,
>>>>>>>>>>>> I
>>>>>>>>>>>>
>>>>>>>>>>>> will do it soon)
>>>>>>>>>>>>
>>>>>>>>>>>>> Try out changing your extension to ".html" to see if it's the
>>>>>>>>>>>>> same
>>>>>>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>>>>>>
>>>>>>>>>>>>> case,
>>>>>>>>>>>>>
>>>>>>>>>>>> "csv"
>>>>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>>
>>>>>>>>>>>> WBR
>>>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>> WBR
>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>> WBR
>>>>>>>> Maxim aka solomax
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>


Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
I have modified my quickstart https://github.com/solomax/ajax-download

disposition set to ATTACHMENT

problems so far:
1) only one AjaxDownload on the page works (example:
https://github.com/solomax/ajax-download/commit/ed5c8f898318da9933369c4bc5ecb5f12fb046c1
)
2) setting file name has no effect: for whatever reason file being
downloaded has random UUID name for blob and "download" for iframe, and
"zip" as extension

Quickstart now contains 4 buttons, each generates different "dynamic"
content
Please check

On Thu, Apr 13, 2017 at 4:17 AM, Sven Meier <sv...@meiers.net> wrote:

> Hi Martin,
>
> actually I meant that FileSystemResource could have a way to *configure*
> the content disposition.
>
> There seems to be some duplication emerging between FileSystemResource and
> ResourceStreamResource now.
>
> Regards
>
> Sven
>
>
>
> On 12.04.2017 22:33, Martin Grigorov wrote:
>
>> Hi Sven,
>>
>> This is another thing that could be added to FileSystemResource besides
>>>
>> the file name.
>>
>> Why do you think it is safe to assume that ATTACHMENT should be set ?
>> I see
>> that org.apache.wicket.request.resource.BaseDataResource#newResou
>> rceResponse()
>> does this.
>> But org.apache.wicket.request.resource.ContextRelativeResource#n
>> ewResourceResponse()
>> and org.apache.wicket.request.resource.ResourceStreamResource#ne
>> wResourceResponse()
>> set the filename without setting the content disposition.
>> org.apache.wicket.request.resource.AbstractResource.Resource
>> Response#contentDisposition
>> is INLINE by default.
>>
>> I'll improve the javadoc of AjaxDownload that the content disposition
>> should be set manually by the application and that INLINE could be used
>> only with Location.NewWindow
>>
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>> On Wed, Apr 12, 2017 at 3:09 PM, Sven Meier <sv...@meiers.net> wrote:
>>
>> Hi Maxim,
>>>
>>> the resource is responsible to set the right content disposition.
>>>
>>> This is another thing that could be added to FileSystemResource besides
>>> the file name.
>>>
>>> Have fun
>>> Sven
>>>
>>>
>>>
>>> On 12.04.2017 14:39, Maxim Solodovnik wrote:
>>>
>>> I thought Attachment is set by default since it is download ....
>>>> Should I retest with it?
>>>>
>>>> Can invalid file name be caused by wrong disposition type?
>>>>
>>>> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>>>>
>>>> Hi,
>>>>
>>>>> you have to set the content disposition too:
>>>>>
>>>>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>>>>
>>>>> We could improve the JavaScript so it is more lenient and works without
>>>>> "attachment" in the header.
>>>>>
>>>>> Have fun
>>>>> Sven
>>>>>
>>>>>
>>>>>
>>>>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>>>>
>>>>> In case I'm setting Location as iFrame, file being downloaded is
>>>>>
>>>>>> "download.zip"
>>>>>> The file name set is also has no effect
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <
>>>>>> solomax666@gmail.com
>>>>>> wrote:
>>>>>>
>>>>>> Weird enough
>>>>>>
>>>>>> I have changed the code to produce pain text file (And it is being
>>>>>>> created
>>>>>>> and has valid text)
>>>>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>>>>> like it was cached somewhere in the browser
>>>>>>>
>>>>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>>
>>>>>>> Then, set the content type to text/html so see if the filename is
>>>>>>> correct
>>>>>>>
>>>>>>> in that case.
>>>>>>>>
>>>>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>>>>> solomax666@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>>>>>
>>>>>>>> downloaded as <UUID>.zip
>>>>>>>>> I guess "zip" is being set from content type
>>>>>>>>> File name is just ignored
>>>>>>>>>
>>>>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> I know, it's just to test the filename...
>>>>>>>>>
>>>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>>>>
>>>>>>>>>> solomax666@gmail.com
>>>>>>>>>>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>>>>
>>>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>>>>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>>>
>>>>>>>>> this,
>>>>>>>>>>
>>>>>>>>>>> I
>>>>>>>>>>>
>>>>>>>>>>> will do it soon)
>>>>>>>>>>>
>>>>>>>>>>>> Try out changing your extension to ".html" to see if it's the
>>>>>>>>>>>> same
>>>>>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>>>>>
>>>>>>>>>>>> case,
>>>>>>>>>>>>
>>>>>>>>>>> "csv"
>>>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>>
>>>>>>>>>>> WBR
>>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>> WBR
>>>>>>>>> Maxim aka solomax
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>> WBR
>>>>>>> Maxim aka solomax
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>


-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sven Meier <sv...@meiers.net>.
Hi Martin,

actually I meant that FileSystemResource could have a way to *configure* 
the content disposition.

There seems to be some duplication emerging between FileSystemResource 
and ResourceStreamResource now.

Regards

Sven


On 12.04.2017 22:33, Martin Grigorov wrote:
> Hi Sven,
>
>> This is another thing that could be added to FileSystemResource besides
> the file name.
>
> Why do you think it is safe to assume that ATTACHMENT should be set ?
> I see
> that org.apache.wicket.request.resource.BaseDataResource#newResourceResponse()
> does this.
> But org.apache.wicket.request.resource.ContextRelativeResource#newResourceResponse()
> and org.apache.wicket.request.resource.ResourceStreamResource#newResourceResponse()
> set the filename without setting the content disposition.
> org.apache.wicket.request.resource.AbstractResource.ResourceResponse#contentDisposition
> is INLINE by default.
>
> I'll improve the javadoc of AjaxDownload that the content disposition
> should be set manually by the application and that INLINE could be used
> only with Location.NewWindow
>
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Apr 12, 2017 at 3:09 PM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi Maxim,
>>
>> the resource is responsible to set the right content disposition.
>>
>> This is another thing that could be added to FileSystemResource besides
>> the file name.
>>
>> Have fun
>> Sven
>>
>>
>>
>> On 12.04.2017 14:39, Maxim Solodovnik wrote:
>>
>>> I thought Attachment is set by default since it is download ....
>>> Should I retest with it?
>>>
>>> Can invalid file name be caused by wrong disposition type?
>>>
>>> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>>>
>>> Hi,
>>>> you have to set the content disposition too:
>>>>
>>>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>>>
>>>> We could improve the JavaScript so it is more lenient and works without
>>>> "attachment" in the header.
>>>>
>>>> Have fun
>>>> Sven
>>>>
>>>>
>>>>
>>>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>>>
>>>> In case I'm setting Location as iFrame, file being downloaded is
>>>>> "download.zip"
>>>>> The file name set is also has no effect
>>>>>
>>>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <solomax666@gmail.com
>>>>> wrote:
>>>>>
>>>>> Weird enough
>>>>>
>>>>>> I have changed the code to produce pain text file (And it is being
>>>>>> created
>>>>>> and has valid text)
>>>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>>>> like it was cached somewhere in the browser
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>
>>>>>> Then, set the content type to text/html so see if the filename is
>>>>>> correct
>>>>>>
>>>>>>> in that case.
>>>>>>>
>>>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>>>> solomax666@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>>>>
>>>>>>>> downloaded as <UUID>.zip
>>>>>>>> I guess "zip" is being set from content type
>>>>>>>> File name is just ignored
>>>>>>>>
>>>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>>>
>>>>>>>> I know, it's just to test the filename...
>>>>>>>>
>>>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>>>
>>>>>>>>> solomax666@gmail.com
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>>>
>>>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>>
>>>>>>>>> this,
>>>>>>>>>> I
>>>>>>>>>>
>>>>>>>>>> will do it soon)
>>>>>>>>>>> Try out changing your extension to ".html" to see if it's the same
>>>>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>>>>
>>>>>>>>>>> case,
>>>>>>>>> "csv"
>>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>> WBR
>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>> WBR
>>>>>>>> Maxim aka solomax
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>> WBR
>>>>>> Maxim aka solomax
>>>>>>
>>>>>>
>>>>>>


Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sven Meier <sv...@meiers.net>.
Hi,

 >Actually this information was already there for IFrame, SameWindow and
 >NewWindow. I've added it only to Location.Blob.

I've changed the JavaScript so it no longer checks for "attachment" in 
the content-disposition. As long as there is a file name present, it 
will be used.

Hence there's no need for this information in Blob's JavaDoc ... and 
people don't have to read it neither.

Have fun
Sven


On 12.04.2017 22:39, Martin Grigorov wrote:
> On Wed, Apr 12, 2017 at 10:33 PM, Martin Grigorov <mg...@apache.org>
> wrote:
>
>> Hi Sven,
>>
>>> This is another thing that could be added to FileSystemResource besides
>> the file name.
>>
>> Why do you think it is safe to assume that ATTACHMENT should be set ?
>> I see that org.apache.wicket.request.resource.BaseDataResource#newResourceResponse()
>> does this.
>> But org.apache.wicket.request.resource.ContextRelativeResource#newResourceResponse()
>> and org.apache.wicket.request.resource.ResourceStreamResource#newResourceResponse()
>> set the filename without setting the content disposition.
>> org.apache.wicket.request.resource.AbstractResource.ResourceResponse#contentDisposition
>> is INLINE by default.
>>
>> I'll improve the javadoc of AjaxDownload that the content disposition
>> should be set manually by the application and that INLINE could be used
>> only with Location.NewWindow
>>
> Actually this information was already there for IFrame, SameWindow and
> NewWindow. I've added it only to Location.Blob.
>
>
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>> On Wed, Apr 12, 2017 at 3:09 PM, Sven Meier <sv...@meiers.net> wrote:
>>
>>> Hi Maxim,
>>>
>>> the resource is responsible to set the right content disposition.
>>>
>>> This is another thing that could be added to FileSystemResource besides
>>> the file name.
>>>
>>> Have fun
>>> Sven
>>>
>>>
>>>
>>> On 12.04.2017 14:39, Maxim Solodovnik wrote:
>>>
>>>> I thought Attachment is set by default since it is download ....
>>>> Should I retest with it?
>>>>
>>>> Can invalid file name be caused by wrong disposition type?
>>>>
>>>> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>>>>
>>>> Hi,
>>>>> you have to set the content disposition too:
>>>>>
>>>>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>>>>
>>>>> We could improve the JavaScript so it is more lenient and works without
>>>>> "attachment" in the header.
>>>>>
>>>>> Have fun
>>>>> Sven
>>>>>
>>>>>
>>>>>
>>>>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>>>>
>>>>> In case I'm setting Location as iFrame, file being downloaded is
>>>>>> "download.zip"
>>>>>> The file name set is also has no effect
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <
>>>>>> solomax666@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> Weird enough
>>>>>>
>>>>>>> I have changed the code to produce pain text file (And it is being
>>>>>>> created
>>>>>>> and has valid text)
>>>>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>>>>> like it was cached somewhere in the browser
>>>>>>>
>>>>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>>
>>>>>>> Then, set the content type to text/html so see if the filename is
>>>>>>> correct
>>>>>>>
>>>>>>>> in that case.
>>>>>>>>
>>>>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>>>>> solomax666@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>>>>>
>>>>>>>>> downloaded as <UUID>.zip
>>>>>>>>> I guess "zip" is being set from content type
>>>>>>>>> File name is just ignored
>>>>>>>>>
>>>>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> I know, it's just to test the filename...
>>>>>>>>>
>>>>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>>>>
>>>>>>>>>> solomax666@gmail.com
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>>>>
>>>>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>>>>
>>>>>>>>>>> wrote:
>>>>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>>>
>>>>>>>>>> this,
>>>>>>>>>>> I
>>>>>>>>>>>
>>>>>>>>>>> will do it soon)
>>>>>>>>>>>> Try out changing your extension to ".html" to see if it's the
>>>>>>>>>>>> same
>>>>>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>>>>>
>>>>>>>>>>>> case,
>>>>>>>>>> "csv"
>>>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>> WBR
>>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>> WBR
>>>>>>>>> Maxim aka solomax
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>> WBR
>>>>>>> Maxim aka solomax
>>>>>>>
>>>>>>>
>>>>>>>


Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Apr 12, 2017 at 10:33 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi Sven,
>
> > This is another thing that could be added to FileSystemResource besides
> the file name.
>
> Why do you think it is safe to assume that ATTACHMENT should be set ?
> I see that org.apache.wicket.request.resource.BaseDataResource#newResourceResponse()
> does this.
> But org.apache.wicket.request.resource.ContextRelativeResource#newResourceResponse()
> and org.apache.wicket.request.resource.ResourceStreamResource#newResourceResponse()
> set the filename without setting the content disposition.
> org.apache.wicket.request.resource.AbstractResource.ResourceResponse#contentDisposition
> is INLINE by default.
>
> I'll improve the javadoc of AjaxDownload that the content disposition
> should be set manually by the application and that INLINE could be used
> only with Location.NewWindow
>

Actually this information was already there for IFrame, SameWindow and
NewWindow. I've added it only to Location.Blob.


>
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Apr 12, 2017 at 3:09 PM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi Maxim,
>>
>> the resource is responsible to set the right content disposition.
>>
>> This is another thing that could be added to FileSystemResource besides
>> the file name.
>>
>> Have fun
>> Sven
>>
>>
>>
>> On 12.04.2017 14:39, Maxim Solodovnik wrote:
>>
>>> I thought Attachment is set by default since it is download ....
>>> Should I retest with it?
>>>
>>> Can invalid file name be caused by wrong disposition type?
>>>
>>> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>>>
>>> Hi,
>>>>
>>>> you have to set the content disposition too:
>>>>
>>>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>>>
>>>> We could improve the JavaScript so it is more lenient and works without
>>>> "attachment" in the header.
>>>>
>>>> Have fun
>>>> Sven
>>>>
>>>>
>>>>
>>>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>>>
>>>> In case I'm setting Location as iFrame, file being downloaded is
>>>>> "download.zip"
>>>>> The file name set is also has no effect
>>>>>
>>>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <
>>>>> solomax666@gmail.com>
>>>>> wrote:
>>>>>
>>>>> Weird enough
>>>>>
>>>>>> I have changed the code to produce pain text file (And it is being
>>>>>> created
>>>>>> and has valid text)
>>>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>>>> like it was cached somewhere in the browser
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>
>>>>>> Then, set the content type to text/html so see if the filename is
>>>>>> correct
>>>>>>
>>>>>>> in that case.
>>>>>>>
>>>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>>>> solomax666@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>>>>
>>>>>>>> downloaded as <UUID>.zip
>>>>>>>> I guess "zip" is being set from content type
>>>>>>>> File name is just ignored
>>>>>>>>
>>>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> I know, it's just to test the filename...
>>>>>>>>
>>>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>>>
>>>>>>>>> solomax666@gmail.com
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>>>
>>>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>>>
>>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>>
>>>>>>>>> this,
>>>>>>>>>> I
>>>>>>>>>>
>>>>>>>>>> will do it soon)
>>>>>>>>>>> Try out changing your extension to ".html" to see if it's the
>>>>>>>>>>> same
>>>>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>>>>
>>>>>>>>>>> case,
>>>>>>>>>>
>>>>>>>>> "csv"
>>>>>>>>
>>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>> WBR
>>>>>>>>>> Maxim aka solomax
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>> WBR
>>>>>>>> Maxim aka solomax
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>> WBR
>>>>>> Maxim aka solomax
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>>
>

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Martin Grigorov <mg...@apache.org>.
Hi Sven,

> This is another thing that could be added to FileSystemResource besides
the file name.

Why do you think it is safe to assume that ATTACHMENT should be set ?
I see
that org.apache.wicket.request.resource.BaseDataResource#newResourceResponse()
does this.
But org.apache.wicket.request.resource.ContextRelativeResource#newResourceResponse()
and org.apache.wicket.request.resource.ResourceStreamResource#newResourceResponse()
set the filename without setting the content disposition.
org.apache.wicket.request.resource.AbstractResource.ResourceResponse#contentDisposition
is INLINE by default.

I'll improve the javadoc of AjaxDownload that the content disposition
should be set manually by the application and that INLINE could be used
only with Location.NewWindow


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Apr 12, 2017 at 3:09 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi Maxim,
>
> the resource is responsible to set the right content disposition.
>
> This is another thing that could be added to FileSystemResource besides
> the file name.
>
> Have fun
> Sven
>
>
>
> On 12.04.2017 14:39, Maxim Solodovnik wrote:
>
>> I thought Attachment is set by default since it is download ....
>> Should I retest with it?
>>
>> Can invalid file name be caused by wrong disposition type?
>>
>> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>>
>> Hi,
>>>
>>> you have to set the content disposition too:
>>>
>>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>>
>>> We could improve the JavaScript so it is more lenient and works without
>>> "attachment" in the header.
>>>
>>> Have fun
>>> Sven
>>>
>>>
>>>
>>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>>
>>> In case I'm setting Location as iFrame, file being downloaded is
>>>> "download.zip"
>>>> The file name set is also has no effect
>>>>
>>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <solomax666@gmail.com
>>>> >
>>>> wrote:
>>>>
>>>> Weird enough
>>>>
>>>>> I have changed the code to produce pain text file (And it is being
>>>>> created
>>>>> and has valid text)
>>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>>> like it was cached somewhere in the browser
>>>>>
>>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>>>
>>>>> Then, set the content type to text/html so see if the filename is
>>>>> correct
>>>>>
>>>>>> in that case.
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>>> solomax666@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>>>
>>>>>>> downloaded as <UUID>.zip
>>>>>>> I guess "zip" is being set from content type
>>>>>>> File name is just ignored
>>>>>>>
>>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>>
>>>>>>> I know, it's just to test the filename...
>>>>>>>
>>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>>
>>>>>>>> solomax666@gmail.com
>>>>>>> wrote:
>>>>>>>
>>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>>
>>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>>
>>>>>>>>> wrote:
>>>>>>>>
>>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>
>>>>>>>> this,
>>>>>>>>> I
>>>>>>>>>
>>>>>>>>> will do it soon)
>>>>>>>>>> Try out changing your extension to ".html" to see if it's the same
>>>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>>>
>>>>>>>>>> case,
>>>>>>>>>
>>>>>>>> "csv"
>>>>>>>
>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>> WBR
>>>>>>>>> Maxim aka solomax
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>> WBR
>>>>>>> Maxim aka solomax
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>> WBR
>>>>> Maxim aka solomax
>>>>>
>>>>>
>>>>>
>>>>
>>
>

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sven Meier <sv...@meiers.net>.
Hi Maxim,

the resource is responsible to set the right content disposition.

This is another thing that could be added to FileSystemResource besides 
the file name.

Have fun
Sven


On 12.04.2017 14:39, Maxim Solodovnik wrote:
> I thought Attachment is set by default since it is download ....
> Should I retest with it?
>
> Can invalid file name be caused by wrong disposition type?
>
> On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:
>
>> Hi,
>>
>> you have to set the content disposition too:
>>
>> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>>
>> We could improve the JavaScript so it is more lenient and works without
>> "attachment" in the header.
>>
>> Have fun
>> Sven
>>
>>
>>
>> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>>
>>> In case I'm setting Location as iFrame, file being downloaded is
>>> "download.zip"
>>> The file name set is also has no effect
>>>
>>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <so...@gmail.com>
>>> wrote:
>>>
>>> Weird enough
>>>> I have changed the code to produce pain text file (And it is being
>>>> created
>>>> and has valid text)
>>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>>> like it was cached somewhere in the browser
>>>>
>>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>>
>>>> Then, set the content type to text/html so see if the filename is correct
>>>>> in that case.
>>>>>
>>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>>> solomax666@gmail.com>
>>>>> wrote:
>>>>>
>>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>>> downloaded as <UUID>.zip
>>>>>> I guess "zip" is being set from content type
>>>>>> File name is just ignored
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
>>>>>>
>>>>>> I know, it's just to test the filename...
>>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>>
>>>>>> solomax666@gmail.com
>>>>>> wrote:
>>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>>
>>>>>>> wrote:
>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>> this,
>>>>>>>> I
>>>>>>>>
>>>>>>>>> will do it soon)
>>>>>>>>> Try out changing your extension to ".html" to see if it's the same
>>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>>
>>>>>>>> case,
>>>>>> "csv"
>>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>>
>>>>>>>>>
>>>>>>>> --
>>>>>>>> WBR
>>>>>>>> Maxim aka solomax
>>>>>>>>
>>>>>>>>
>>>>>> --
>>>>>> WBR
>>>>>> Maxim aka solomax
>>>>>>
>>>>>>
>>>> --
>>>> WBR
>>>> Maxim aka solomax
>>>>
>>>>
>>>
>


Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
I thought Attachment is set by default since it is download ....
Should I retest with it?

Can invalid file name be caused by wrong disposition type?

On Wed, Apr 12, 2017 at 6:46 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi,
>
> you have to set the content disposition too:
>
> response.setContentDisposition(ContentDisposition.ATTACHMENT);
>
> We could improve the JavaScript so it is more lenient and works without
> "attachment" in the header.
>
> Have fun
> Sven
>
>
>
> On 12.04.2017 12:32, Maxim Solodovnik wrote:
>
>> In case I'm setting Location as iFrame, file being downloaded is
>> "download.zip"
>> The file name set is also has no effect
>>
>> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <so...@gmail.com>
>> wrote:
>>
>> Weird enough
>>> I have changed the code to produce pain text file (And it is being
>>> created
>>> and has valid text)
>>> But after "mvn clean jetty:run" same zip file is being downloaded
>>> like it was cached somewhere in the browser
>>>
>>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>>
>>> Then, set the content type to text/html so see if the filename is correct
>>>> in that case.
>>>>
>>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
>>>> solomax666@gmail.com>
>>>> wrote:
>>>>
>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>>> downloaded as <UUID>.zip
>>>>> I guess "zip" is being set from content type
>>>>> File name is just ignored
>>>>>
>>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
>>>>>
>>>>> I know, it's just to test the filename...
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>>>>>
>>>>> solomax666@gmail.com
>>>>
>>>>> wrote:
>>>>>>
>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>>
>>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>>>>>>
>>>>>> wrote:
>>>>
>>>>> I did the same problem recently (I still have to answer Sven about
>>>>>>>>
>>>>>>> this,
>>>>>>
>>>>>>> I
>>>>>>>
>>>>>>>> will do it soon)
>>>>>>>> Try out changing your extension to ".html" to see if it's the same
>>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>>>>>>>
>>>>>>> case,
>>>>
>>>>> "csv"
>>>>>>>
>>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> WBR
>>>>>>> Maxim aka solomax
>>>>>>>
>>>>>>>
>>>>>
>>>>> --
>>>>> WBR
>>>>> Maxim aka solomax
>>>>>
>>>>>
>>>
>>> --
>>> WBR
>>> Maxim aka solomax
>>>
>>>
>>
>>
>


-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you have to set the content disposition too:

response.setContentDisposition(ContentDisposition.ATTACHMENT);

We could improve the JavaScript so it is more lenient and works without 
"attachment" in the header.

Have fun
Sven


On 12.04.2017 12:32, Maxim Solodovnik wrote:
> In case I'm setting Location as iFrame, file being downloaded is
> "download.zip"
> The file name set is also has no effect
>
> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
>> Weird enough
>> I have changed the code to produce pain text file (And it is being created
>> and has valid text)
>> But after "mvn clean jetty:run" same zip file is being downloaded
>> like it was cached somewhere in the browser
>>
>> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>>
>>> Then, set the content type to text/html so see if the filename is correct
>>> in that case.
>>>
>>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <so...@gmail.com>
>>> wrote:
>>>
>>>> In case I'm setting file name to "backp.zip.html" the file is being
>>>> downloaded as <UUID>.zip
>>>> I guess "zip" is being set from content type
>>>> File name is just ignored
>>>>
>>>> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
>>>>
>>>>> I know, it's just to test the filename...
>>>>>
>>>>> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>>> solomax666@gmail.com
>>>>> wrote:
>>>>>
>>>>>> But I need zip extension, otherwise it will be unusable ....
>>>>>>
>>>>>> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>>> wrote:
>>>>>>> I did the same problem recently (I still have to answer Sven about
>>>>> this,
>>>>>> I
>>>>>>> will do it soon)
>>>>>>> Try out changing your extension to ".html" to see if it's the same
>>>>>>> behavior, maybe it will help you to investigate further. (in my
>>> case,
>>>>>> "csv"
>>>>>>> had issue with the filename and "html" was fine)
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> WBR
>>>>>> Maxim aka solomax
>>>>>>
>>>>
>>>>
>>>> --
>>>> WBR
>>>> Maxim aka solomax
>>>>
>>
>>
>> --
>> WBR
>> Maxim aka solomax
>>
>
>


Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
I'm not sure issue is caused by FileSystemResource
I believe it is caused by AjaxDownload

Here is example with 2 AjaxDownloads on the page
https://github.com/solomax/ajax-download

it doesn't work this way
File name also is not being set

On Wed, Apr 12, 2017 at 5:53 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Maxim,
>
> Please create a quickstart and attach it to the ticket for
> FileSystemResource!
> We have to improve this!
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Apr 12, 2017 at 12:32 PM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > In case I'm setting Location as iFrame, file being downloaded is
> > "download.zip"
> > The file name set is also has no effect
> >
> > On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <so...@gmail.com>
> > wrote:
> >
> > > Weird enough
> > > I have changed the code to produce pain text file (And it is being
> > created
> > > and has valid text)
> > > But after "mvn clean jetty:run" same zip file is being downloaded
> > > like it was cached somewhere in the browser
> > >
> > > On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
> > >
> > >> Then, set the content type to text/html so see if the filename is
> > correct
> > >> in that case.
> > >>
> > >> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
> > solomax666@gmail.com>
> > >> wrote:
> > >>
> > >> > In case I'm setting file name to "backp.zip.html" the file is being
> > >> > downloaded as <UUID>.zip
> > >> > I guess "zip" is being set from content type
> > >> > File name is just ignored
> > >> >
> > >> > On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com>
> wrote:
> > >> >
> > >> > > I know, it's just to test the filename...
> > >> > >
> > >> > > On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
> > >> solomax666@gmail.com
> > >> > >
> > >> > > wrote:
> > >> > >
> > >> > > > But I need zip extension, otherwise it will be unusable ....
> > >> > > >
> > >> > > > On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
> > >> wrote:
> > >> > > >
> > >> > > > > I did the same problem recently (I still have to answer Sven
> > about
> > >> > > this,
> > >> > > > I
> > >> > > > > will do it soon)
> > >> > > > > Try out changing your extension to ".html" to see if it's the
> > same
> > >> > > > > behavior, maybe it will help you to investigate further. (in
> my
> > >> case,
> > >> > > > "csv"
> > >> > > > > had issue with the filename and "html" was fine)
> > >> > > > >
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > > --
> > >> > > > WBR
> > >> > > > Maxim aka solomax
> > >> > > >
> > >> > >
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > WBR
> > >> > Maxim aka solomax
> > >> >
> > >>
> > >
> > >
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Martin Grigorov <mg...@apache.org>.
Maxim,

Please create a quickstart and attach it to the ticket for
FileSystemResource!
We have to improve this!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Apr 12, 2017 at 12:32 PM, Maxim Solodovnik <so...@gmail.com>
wrote:

> In case I'm setting Location as iFrame, file being downloaded is
> "download.zip"
> The file name set is also has no effect
>
> On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > Weird enough
> > I have changed the code to produce pain text file (And it is being
> created
> > and has valid text)
> > But after "mvn clean jetty:run" same zip file is being downloaded
> > like it was cached somewhere in the browser
> >
> > On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
> >
> >> Then, set the content type to text/html so see if the filename is
> correct
> >> in that case.
> >>
> >> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <
> solomax666@gmail.com>
> >> wrote:
> >>
> >> > In case I'm setting file name to "backp.zip.html" the file is being
> >> > downloaded as <UUID>.zip
> >> > I guess "zip" is being set from content type
> >> > File name is just ignored
> >> >
> >> > On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
> >> >
> >> > > I know, it's just to test the filename...
> >> > >
> >> > > On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
> >> solomax666@gmail.com
> >> > >
> >> > > wrote:
> >> > >
> >> > > > But I need zip extension, otherwise it will be unusable ....
> >> > > >
> >> > > > On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
> >> wrote:
> >> > > >
> >> > > > > I did the same problem recently (I still have to answer Sven
> about
> >> > > this,
> >> > > > I
> >> > > > > will do it soon)
> >> > > > > Try out changing your extension to ".html" to see if it's the
> same
> >> > > > > behavior, maybe it will help you to investigate further. (in my
> >> case,
> >> > > > "csv"
> >> > > > > had issue with the filename and "html" was fine)
> >> > > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > --
> >> > > > WBR
> >> > > > Maxim aka solomax
> >> > > >
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > WBR
> >> > Maxim aka solomax
> >> >
> >>
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
In case I'm setting Location as iFrame, file being downloaded is
"download.zip"
The file name set is also has no effect

On Wed, Apr 12, 2017 at 5:12 PM, Maxim Solodovnik <so...@gmail.com>
wrote:

> Weird enough
> I have changed the code to produce pain text file (And it is being created
> and has valid text)
> But after "mvn clean jetty:run" same zip file is being downloaded
> like it was cached somewhere in the browser
>
> On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:
>
>> Then, set the content type to text/html so see if the filename is correct
>> in that case.
>>
>> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <so...@gmail.com>
>> wrote:
>>
>> > In case I'm setting file name to "backp.zip.html" the file is being
>> > downloaded as <UUID>.zip
>> > I guess "zip" is being set from content type
>> > File name is just ignored
>> >
>> > On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
>> >
>> > > I know, it's just to test the filename...
>> > >
>> > > On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
>> solomax666@gmail.com
>> > >
>> > > wrote:
>> > >
>> > > > But I need zip extension, otherwise it will be unusable ....
>> > > >
>> > > > On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com>
>> wrote:
>> > > >
>> > > > > I did the same problem recently (I still have to answer Sven about
>> > > this,
>> > > > I
>> > > > > will do it soon)
>> > > > > Try out changing your extension to ".html" to see if it's the same
>> > > > > behavior, maybe it will help you to investigate further. (in my
>> case,
>> > > > "csv"
>> > > > > had issue with the filename and "html" was fine)
>> > > > >
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > WBR
>> > > > Maxim aka solomax
>> > > >
>> > >
>> >
>> >
>> >
>> > --
>> > WBR
>> > Maxim aka solomax
>> >
>>
>
>
>
> --
> WBR
> Maxim aka solomax
>



-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
Weird enough
I have changed the code to produce pain text file (And it is being created
and has valid text)
But after "mvn clean jetty:run" same zip file is being downloaded
like it was cached somewhere in the browser

On Wed, Apr 12, 2017 at 4:51 PM, Sebastien <se...@gmail.com> wrote:

> Then, set the content type to text/html so see if the filename is correct
> in that case.
>
> On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > In case I'm setting file name to "backp.zip.html" the file is being
> > downloaded as <UUID>.zip
> > I guess "zip" is being set from content type
> > File name is just ignored
> >
> > On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
> >
> > > I know, it's just to test the filename...
> > >
> > > On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <
> solomax666@gmail.com
> > >
> > > wrote:
> > >
> > > > But I need zip extension, otherwise it will be unusable ....
> > > >
> > > > On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com> wrote:
> > > >
> > > > > I did the same problem recently (I still have to answer Sven about
> > > this,
> > > > I
> > > > > will do it soon)
> > > > > Try out changing your extension to ".html" to see if it's the same
> > > > > behavior, maybe it will help you to investigate further. (in my
> case,
> > > > "csv"
> > > > > had issue with the filename and "html" was fine)
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > WBR
> > > > Maxim aka solomax
> > > >
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sebastien <se...@gmail.com>.
Then, set the content type to text/html so see if the filename is correct
in that case.

On Wed, Apr 12, 2017 at 11:44 AM, Maxim Solodovnik <so...@gmail.com>
wrote:

> In case I'm setting file name to "backp.zip.html" the file is being
> downloaded as <UUID>.zip
> I guess "zip" is being set from content type
> File name is just ignored
>
> On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:
>
> > I know, it's just to test the filename...
> >
> > On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <solomax666@gmail.com
> >
> > wrote:
> >
> > > But I need zip extension, otherwise it will be unusable ....
> > >
> > > On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com> wrote:
> > >
> > > > I did the same problem recently (I still have to answer Sven about
> > this,
> > > I
> > > > will do it soon)
> > > > Try out changing your extension to ".html" to see if it's the same
> > > > behavior, maybe it will help you to investigate further. (in my case,
> > > "csv"
> > > > had issue with the filename and "html" was fine)
> > > >
> > >
> > >
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
In case I'm setting file name to "backp.zip.html" the file is being
downloaded as <UUID>.zip
I guess "zip" is being set from content type
File name is just ignored

On Wed, Apr 12, 2017 at 4:38 PM, Sebastien <se...@gmail.com> wrote:

> I know, it's just to test the filename...
>
> On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > But I need zip extension, otherwise it will be unusable ....
> >
> > On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com> wrote:
> >
> > > I did the same problem recently (I still have to answer Sven about
> this,
> > I
> > > will do it soon)
> > > Try out changing your extension to ".html" to see if it's the same
> > > behavior, maybe it will help you to investigate further. (in my case,
> > "csv"
> > > had issue with the filename and "html" was fine)
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sebastien <se...@gmail.com>.
I know, it's just to test the filename...

On Wed, Apr 12, 2017 at 11:29 AM, Maxim Solodovnik <so...@gmail.com>
wrote:

> But I need zip extension, otherwise it will be unusable ....
>
> On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com> wrote:
>
> > I did the same problem recently (I still have to answer Sven about this,
> I
> > will do it soon)
> > Try out changing your extension to ".html" to see if it's the same
> > behavior, maybe it will help you to investigate further. (in my case,
> "csv"
> > had issue with the filename and "html" was fine)
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
But I need zip extension, otherwise it will be unusable ....

On Wed, Apr 12, 2017 at 4:27 PM, Sebastien <se...@gmail.com> wrote:

> I did the same problem recently (I still have to answer Sven about this, I
> will do it soon)
> Try out changing your extension to ".html" to see if it's the same
> behavior, maybe it will help you to investigate further. (in my case, "csv"
> had issue with the filename and "html" was fine)
>



-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Sebastien <se...@gmail.com>.
I did the same problem recently (I still have to answer Sven about this, I
will do it soon)
Try out changing your extension to ".html" to see if it's the same
behavior, maybe it will help you to investigate further. (in my case, "csv"
had issue with the filename and "html" was fine)

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Maxim Solodovnik <so...@gmail.com>.
It called only once, Correct file name is being set
But file is being downloaded with UUID as name

On Wed, Apr 12, 2017 at 4:10 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi Maxim,
>
> Put a breakpoint at ResourceResponse.setFileName(String) and see how many
> times it is called and with what values.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Apr 12, 2017 at 11:07 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > Hello All,
> >
> > I have updated my project
> > https://github.com/solomax/ajax-download/commit/
> > 453663a55f390e54354381ab0f009d194e37e87c
> > To set filename
> > But file being downloaded has random UUID as file name, what am I doing
> > wrong?
> >
> > On Wed, Mar 29, 2017 at 9:31 PM, Maxim Solodovnik <so...@gmail.com>
> > wrote:
> >
> > > Will try to migrate all my use cases on a SNAPSHOT first
> > > Then will do
> > > Thanks Martin!
> > >
> > > On Wed, Mar 29, 2017 at 9:28 PM, Martin Grigorov <mgrigorov@apache.org
> >
> > > wrote:
> > > > Maxim, you can use Location.IFrame or Location.SameWindow too in -M5
> > (to
> > > be
> > > > released!).
> > > >
> > > > Martin Grigorov
> > > > Wicket Training and Consulting
> > > > https://twitter.com/mtgrigorov
> > > >
> > > > On Wed, Mar 29, 2017 at 4:26 PM, Sven Meier <sv...@meiers.net> wrote:
> > > >
> > > >> In a minute :P
> > > >>
> > > >> Sven
> > > >>
> > > >>
> > > >>
> > > >> On 29.03.2017 16:15, Andrea Del Bene wrote:
> > > >>
> > > >>> Right when we will return to "success" :-)
> > > >>>
> > > >>> https://ci.apache.org/builders/wicket-master
> > > >>>
> > > >>> On Wed, Mar 29, 2017 at 4:07 PM, Maxim Solodovnik <
> > > solomax666@gmail.com>
> > > >>> wrote:
> > > >>>
> > > >>> Wow, Thanks a lot!
> > > >>>> Could you please let me know when SNAPSHOT with the fix will be
> > > >>>> available?
> > > >>>>
> > > >>>> On Wed, Mar 29, 2017 at 8:50 PM, Sven Meier <sv...@meiers.net>
> > wrote:
> > > >>>>
> > > >>>>> Hi,
> > > >>>>>
> > > >>>>> so we have to change the Location.Blob to use XMLHttpRequest
> > > directly,
> > > >>>>> because jQuery does not support blob downloads :/.
> > > >>>>>
> > > >>>>> I've change the JavaScript and now downloading of the zip works
> > fine.
> > > >>>>>
> > > >>>>> FileSystemResource might not be the best candidate (because it's
> > not
> > > >>>>> serializable), but you can use an indirection to prevent it being
> > > >>>>>
> > > >>>> serialized
> > > >>>>
> > > >>>>> along with AjaxDownload:
> > > >>>>>
> > > >>>>>          final AjaxDownload download = new AjaxDownload(
> > > >>>>>              new IResource()
> > > >>>>>              {
> > > >>>>>                  @Override
> > > >>>>>                  public void respond(Attributes attributes)
> > > >>>>>                  {
> > > >>>>>                      new
> > > >>>>> FileSystemResource(zipFile.toPath()).respond(attributes);
> > > >>>>>                  }
> > > >>>>>              }
> > > >>>>>          );
> > > >>>>>
> > > >>>>> Have fun
> > > >>>>> Sven
> > > >>>>>
> > > >>>>>
> > > >>>>>
> > > >>>>> On 29.03.2017 15:12, Maxim Solodovnik wrote:
> > > >>>>>
> > > >>>>>> Filename is minor issue ....
> > > >>>>>> Main problem is invalid file :(
> > > >>>>>>
> > > >>>>>> How can I serve the file from file system? I thought
> > > >>>>>> filesystemreference
> > > >>>>>> if
> > > >>>>>> the best candidate .....
> > > >>>>>>
> > > >>>>>> WBR, Maxim
> > > >>>>>> (from mobile, sorry for the typos)
> > > >>>>>>
> > > >>>>>> On Mar 29, 2017 8:08 PM, "Sven Meier" <sv...@meiers.net> wrote:
> > > >>>>>>
> > > >>>>>> Hi Maxim,
> > > >>>>>>>
> > > >>>>>>> three things:
> > > >>>>>>>
> > > >>>>>>> - filename ... no one sets the file name :P
> > > >>>>>>>
> > > >>>>>>> - serializable error ... FileSystemResource holds a reference
> to
> > > the
> > > >>>>>>> path,
> > > >>>>>>> which is not serializable
> > > >>>>>>>
> > > >>>>>>> - corruct zip ... my bad, it seems that Location.Blob mangles
> the
> > > file
> > > >>>>>>>
> > > >>>>>> on
> > > >>>>
> > > >>>>> the client side
> > > >>>>>>>
> > > >>>>>>> I'll see what I can do about Location.Blob - it might be an
> > > encoding
> > > >>>>>>> issue.
> > > >>>>>>>
> > > >>>>>>> Have fun
> > > >>>>>>> Sven
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>> On 29.03.2017 14:15, Maxim Solodovnik wrote:
> > > >>>>>>>
> > > >>>>>>> here you are: https://github.com/solomax/ajax-download
> > > >>>>>>>> Absolutely don't understand what is going on :(
> > > >>>>>>>>
> > > >>>>>>>> On Wed, Mar 29, 2017 at 6:30 PM, Maxim Solodovnik <
> > > >>>>>>>>
> > > >>>>>>> solomax666@gmail.com>
> > > >>>>
> > > >>>>> wrote:
> > > >>>>>>>>
> > > >>>>>>>> Yep, zip file is valid
> > > >>>>>>>>> Breakpoint at AjaxDownload.ResourceBehavior#onRequest() is
> not
> > > hit
> > > >>>>>>>>>
> > > >>>>>>>> :(
> > > >>>>
> > > >>>>> Will try to create quickstart
> > > >>>>>>>>>
> > > >>>>>>>>> something extremely weird
> > > >>>>>>>>>
> > > >>>>>>>>> On Wed, Mar 29, 2017 at 2:22 AM, Martin Grigorov <
> > > >>>>>>>>>
> > > >>>>>>>> mgrigorov@apache.org>
> > > >>>>
> > > >>>>> wrote:
> > > >>>>>>>>>
> > > >>>>>>>>> Hi Maxim,
> > > >>>>>>>>>>
> > > >>>>>>>>>> On Tue, Mar 28, 2017 at 11:06 AM, Maxim Solodovnik <
> > > >>>>>>>>>> solomax666@gmail.com>
> > > >>>>>>>>>> wrote:
> > > >>>>>>>>>>
> > > >>>>>>>>>> Thanks a lot Martin for detailed explanation
> > > >>>>>>>>>>
> > > >>>>>>>>>>> I do have this functionality working with old version of
> > > >>>>>>>>>>>
> > > >>>>>>>>>> AjaxDownload
> > > >>>>
> > > >>>>> And here is my first try to migrate to the new internal wicket
> > > >>>>>>>>>>> AjaxDownload:
> > > >>>>>>>>>>> https://github.com/apache/openmeetings/commit/
> > > >>>>>>>>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> I would appreciate if you can take a look at this tiny
> > commit.
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> Something really doesn't work as expected ....
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> Commited version behaves wrong:
> > > >>>>>>>>>>> 1) file downloaded has wrong name
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> You do not set file name anywhere!
> > > >>>>>>>>>>>
> > > >>>>>>>>>> Keep a reference to the constructed ResourceResponse and
> call
> > > its
> > > >>>>>>>>>> #setFileName(...)
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>> 2) is not valid zip file (cannot be opened)
> > > >>>>>>>>>>
> > > >>>>>>>>>>> Is the backupPath representing a ZIP file ?
> > > >>>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>> 3) for some reason I'm not able to get to breakpoint at line
> > 115
> > > >>>>>>>>>> [1]
> > > >>>>>>>>>>
> > > >>>>>>>>>>> Put a breakpoint at
> > > >>>>>>>>>>> AjaxDownload.ResourceBehavior#onResourceRequested()
> > > >>>>>>>>>>>
> > > >>>>>>>>>> and
> > > >>>>>>>>>> see what happens
> > > >>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>> Additionally I got NotSerializable exception in case I made
> > > >>>>>>>>>>
> > > >>>>>>>>> "download"
> > > >>>>
> > > >>>>> class final variable
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> java.nio.file.Path is not Serializable!
> > > >>>>>>>>>>>
> > > >>>>>>>>>>
> > > >>>>>>>>>> What am I doing wrong?
> > > >>>>>>>>>>
> > > >>>>>>>>>>> [1] https://github.com/apache/openmeetings/commit/
> > > >>>>>>>>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f#diff-
> > > >>>>>>>>>>> 0a499c88998a93ceb51c347836aa6195R115
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> On Thu, Mar 23, 2017 at 3:16 AM, Martin Grigorov
> > > >>>>>>>>>>> <mgrigorov@apache.org
> > > >>>>>>>>>>> wrote:
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> On Wed, Mar 22, 2017 at 12:59 PM, Maxim Solodovnik <
> > > >>>>>>>>>>>> solomax666@gmail.com
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> wrote:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> Actually I have 2 example use cases:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>> 1) user selects files on file tree
> > > >>>>>>>>>>>>> 2) as soon as file is selected and download is enabled
> for
> > > it,
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>> used
> > > >>>>
> > > >>>>> can
> > > >>>>>>>>>>>>> press ajax download button and get the file
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>>> Another case:
> > > >>>>>>>>>>>>> User requests system backup
> > > >>>>>>>>>>>>> As soon as backup is created (Progress complete)
> > > >>>>>>>>>>>>> Download of newly created file should be initiated
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>>> I can't create ResourceReference and override
> > > getResourceStream
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>> of
> > > >>>>
> > > >>>>> it
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>>> since
> > > >>>>>>>>>>>> I only have resource just before download
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>> Wicket IResource is an abstraction over the real
> resource.
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>> In my case i also create the response on the fly. It is
> > > either a
> > > >>>>>>>>>>>> single
> > > >>>>>>>>>>>> File or a Zip file with several entries.
> > > >>>>>>>>>>>> The ResourceReference is more or less just an endpoint
> with
> > > >>>>>>>>>>>> almost
> > > >>>>>>>>>>>> no
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> logic
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> at all. It just creates the IResource.
> > > >>>>>>>>>>>> The IResource uses the information from the request
> > > parameters /
> > > >>>>>>>>>>>> session
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> /
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> somewhere else to create the actual response (the files).
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> AjaxDownload is an Ajax behavior that you can use to
> trigger
> > > the
> > > >>>>>>>>>>>> creation
> > > >>>>>>>>>>>> of the files and by using its callback methods you can
> show
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> feedback
> > > >>>>
> > > >>>>> to
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> the
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> user. To show progress bar you will need to employ
> > ProgressBar
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>> from
> > > >>>>
> > > >>>>> wicket-extentions or use WebSockets.
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>> On Wed, Mar 22, 2017 at 6:53 PM, Martin Grigorov <
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>> mgrigorov@apache.org>
> > > >>>>>>>>>>>>> wrote:
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>>> Hi Maxim,
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>>>> I use the new AjaxDownload with a ResourceReference,
> i.e.
> > > >>>>>>>>>>>>>> AjaxDownload#AjaxDownload(org.apache.wicket.request.
> > > >>>>>>>>>>>>>> resource.ResourceReference,
> > > >>>>>>>>>>>>>> org.apache.wicket.request.mapper.parameter.
> > PageParameters)
> > > >>>>>>>>>>>>>> The ResourceReference has
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>> public IResource getResource() {
> > > >>>>>>>>>>>>>>        return new StatementDownloadResource();
> > > >>>>>>>>>>>>>> }
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>> StatementDownloadResource extends ResourceStreamResource
> > and
> > > >>>>>>>>>>>>>> provides
> > > >>>>>>>>>>>>>> implementation of #getResourceStream(). There I have a
> > logic
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>> that
> > > >>>>
> > > >>>>> returns
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>> either FileResourceStream or ZipResourceStream.
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>> Martin Grigorov
> > > >>>>>>>>>>>>>> Wicket Training and Consulting
> > > >>>>>>>>>>>>>> https://twitter.com/mtgrigorov
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>> On Wed, Mar 22, 2017 at 12:30 PM, Maxim Solodovnik <
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>> solomax666@gmail.com
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>> wrote:
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>> Just have tried to switch to this AjaxDownload component
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>> And it seems I cannot find proper way to use it with
> > > dynamic
> > > >>>>>>>>>>>>>>> file,
> > > >>>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>> i.e.
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>> previously
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>> I created AjaxDownload,
> > > >>>>>>>>>>>>>>> added it to the page
> > > >>>>>>>>>>>>>>> then at the moment I know what file should be served, I
> > set
> > > >>>>>>>>>>>>>>> the
> > > >>>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>> stream
> > > >>>>>>>>>>>>>>
> > > >>>>>>>>>>>>> and
> > > >>>>>>>>>>>>
> > > >>>>>>>>>>>>> initiate the download
> > > >>>>>>>>>>>>>>> (for example one of use cases: I need to create zip
> file
> > > >>>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>> right now this seems to be impossible :(
> > > >>>>>>>>>>>>>>> Can you give me a hint how this dynamic nature can be
> > > >>>>>>>>>>>>>>> implemented?
> > > >>>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>> --
> > > >>>>>>>>>>>>>>> WBR
> > > >>>>>>>>>>>>>>> Maxim aka solomax
> > > >>>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>>
> > > >>>>>>>>>>>>>>> --
> > > >>>>>>>>>>>>> WBR
> > > >>>>>>>>>>>>> Maxim aka solomax
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>>>
> > > >>>>>>>>>>>>> --
> > > >>>>>>>>>>> WBR
> > > >>>>>>>>>>> Maxim aka solomax
> > > >>>>>>>>>>>
> > > >>>>>>>>>>>
> > > >>>>>>>>>>> --
> > > >>>>>>>>> WBR
> > > >>>>>>>>> Maxim aka solomax
> > > >>>>>>>>>
> > > >>>>>>>>>
> > > >>>>>>>>
> > > >>>>
> > > >>>> --
> > > >>>> WBR
> > > >>>> Maxim aka solomax
> > > >>>>
> > > >>>>
> > > >>
> > >
> > >
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: Question regarding new AjaxDownload (WICKET-6286)

Posted by Martin Grigorov <mg...@apache.org>.
Hi Maxim,

Put a breakpoint at ResourceResponse.setFileName(String) and see how many
times it is called and with what values.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Apr 12, 2017 at 11:07 AM, Maxim Solodovnik <so...@gmail.com>
wrote:

> Hello All,
>
> I have updated my project
> https://github.com/solomax/ajax-download/commit/
> 453663a55f390e54354381ab0f009d194e37e87c
> To set filename
> But file being downloaded has random UUID as file name, what am I doing
> wrong?
>
> On Wed, Mar 29, 2017 at 9:31 PM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > Will try to migrate all my use cases on a SNAPSHOT first
> > Then will do
> > Thanks Martin!
> >
> > On Wed, Mar 29, 2017 at 9:28 PM, Martin Grigorov <mg...@apache.org>
> > wrote:
> > > Maxim, you can use Location.IFrame or Location.SameWindow too in -M5
> (to
> > be
> > > released!).
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Wed, Mar 29, 2017 at 4:26 PM, Sven Meier <sv...@meiers.net> wrote:
> > >
> > >> In a minute :P
> > >>
> > >> Sven
> > >>
> > >>
> > >>
> > >> On 29.03.2017 16:15, Andrea Del Bene wrote:
> > >>
> > >>> Right when we will return to "success" :-)
> > >>>
> > >>> https://ci.apache.org/builders/wicket-master
> > >>>
> > >>> On Wed, Mar 29, 2017 at 4:07 PM, Maxim Solodovnik <
> > solomax666@gmail.com>
> > >>> wrote:
> > >>>
> > >>> Wow, Thanks a lot!
> > >>>> Could you please let me know when SNAPSHOT with the fix will be
> > >>>> available?
> > >>>>
> > >>>> On Wed, Mar 29, 2017 at 8:50 PM, Sven Meier <sv...@meiers.net>
> wrote:
> > >>>>
> > >>>>> Hi,
> > >>>>>
> > >>>>> so we have to change the Location.Blob to use XMLHttpRequest
> > directly,
> > >>>>> because jQuery does not support blob downloads :/.
> > >>>>>
> > >>>>> I've change the JavaScript and now downloading of the zip works
> fine.
> > >>>>>
> > >>>>> FileSystemResource might not be the best candidate (because it's
> not
> > >>>>> serializable), but you can use an indirection to prevent it being
> > >>>>>
> > >>>> serialized
> > >>>>
> > >>>>> along with AjaxDownload:
> > >>>>>
> > >>>>>          final AjaxDownload download = new AjaxDownload(
> > >>>>>              new IResource()
> > >>>>>              {
> > >>>>>                  @Override
> > >>>>>                  public void respond(Attributes attributes)
> > >>>>>                  {
> > >>>>>                      new
> > >>>>> FileSystemResource(zipFile.toPath()).respond(attributes);
> > >>>>>                  }
> > >>>>>              }
> > >>>>>          );
> > >>>>>
> > >>>>> Have fun
> > >>>>> Sven
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> On 29.03.2017 15:12, Maxim Solodovnik wrote:
> > >>>>>
> > >>>>>> Filename is minor issue ....
> > >>>>>> Main problem is invalid file :(
> > >>>>>>
> > >>>>>> How can I serve the file from file system? I thought
> > >>>>>> filesystemreference
> > >>>>>> if
> > >>>>>> the best candidate .....
> > >>>>>>
> > >>>>>> WBR, Maxim
> > >>>>>> (from mobile, sorry for the typos)
> > >>>>>>
> > >>>>>> On Mar 29, 2017 8:08 PM, "Sven Meier" <sv...@meiers.net> wrote:
> > >>>>>>
> > >>>>>> Hi Maxim,
> > >>>>>>>
> > >>>>>>> three things:
> > >>>>>>>
> > >>>>>>> - filename ... no one sets the file name :P
> > >>>>>>>
> > >>>>>>> - serializable error ... FileSystemResource holds a reference to
> > the
> > >>>>>>> path,
> > >>>>>>> which is not serializable
> > >>>>>>>
> > >>>>>>> - corruct zip ... my bad, it seems that Location.Blob mangles the
> > file
> > >>>>>>>
> > >>>>>> on
> > >>>>
> > >>>>> the client side
> > >>>>>>>
> > >>>>>>> I'll see what I can do about Location.Blob - it might be an
> > encoding
> > >>>>>>> issue.
> > >>>>>>>
> > >>>>>>> Have fun
> > >>>>>>> Sven
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> On 29.03.2017 14:15, Maxim Solodovnik wrote:
> > >>>>>>>
> > >>>>>>> here you are: https://github.com/solomax/ajax-download
> > >>>>>>>> Absolutely don't understand what is going on :(
> > >>>>>>>>
> > >>>>>>>> On Wed, Mar 29, 2017 at 6:30 PM, Maxim Solodovnik <
> > >>>>>>>>
> > >>>>>>> solomax666@gmail.com>
> > >>>>
> > >>>>> wrote:
> > >>>>>>>>
> > >>>>>>>> Yep, zip file is valid
> > >>>>>>>>> Breakpoint at AjaxDownload.ResourceBehavior#onRequest() is not
> > hit
> > >>>>>>>>>
> > >>>>>>>> :(
> > >>>>
> > >>>>> Will try to create quickstart
> > >>>>>>>>>
> > >>>>>>>>> something extremely weird
> > >>>>>>>>>
> > >>>>>>>>> On Wed, Mar 29, 2017 at 2:22 AM, Martin Grigorov <
> > >>>>>>>>>
> > >>>>>>>> mgrigorov@apache.org>
> > >>>>
> > >>>>> wrote:
> > >>>>>>>>>
> > >>>>>>>>> Hi Maxim,
> > >>>>>>>>>>
> > >>>>>>>>>> On Tue, Mar 28, 2017 at 11:06 AM, Maxim Solodovnik <
> > >>>>>>>>>> solomax666@gmail.com>
> > >>>>>>>>>> wrote:
> > >>>>>>>>>>
> > >>>>>>>>>> Thanks a lot Martin for detailed explanation
> > >>>>>>>>>>
> > >>>>>>>>>>> I do have this functionality working with old version of
> > >>>>>>>>>>>
> > >>>>>>>>>> AjaxDownload
> > >>>>
> > >>>>> And here is my first try to migrate to the new internal wicket
> > >>>>>>>>>>> AjaxDownload:
> > >>>>>>>>>>> https://github.com/apache/openmeetings/commit/
> > >>>>>>>>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f
> > >>>>>>>>>>>
> > >>>>>>>>>>> I would appreciate if you can take a look at this tiny
> commit.
> > >>>>>>>>>>>
> > >>>>>>>>>>> Something really doesn't work as expected ....
> > >>>>>>>>>>>
> > >>>>>>>>>>> Commited version behaves wrong:
> > >>>>>>>>>>> 1) file downloaded has wrong name
> > >>>>>>>>>>>
> > >>>>>>>>>>> You do not set file name anywhere!
> > >>>>>>>>>>>
> > >>>>>>>>>> Keep a reference to the constructed ResourceResponse and call
> > its
> > >>>>>>>>>> #setFileName(...)
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>> 2) is not valid zip file (cannot be opened)
> > >>>>>>>>>>
> > >>>>>>>>>>> Is the backupPath representing a ZIP file ?
> > >>>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>> 3) for some reason I'm not able to get to breakpoint at line
> 115
> > >>>>>>>>>> [1]
> > >>>>>>>>>>
> > >>>>>>>>>>> Put a breakpoint at
> > >>>>>>>>>>> AjaxDownload.ResourceBehavior#onResourceRequested()
> > >>>>>>>>>>>
> > >>>>>>>>>> and
> > >>>>>>>>>> see what happens
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>> Additionally I got NotSerializable exception in case I made
> > >>>>>>>>>>
> > >>>>>>>>> "download"
> > >>>>
> > >>>>> class final variable
> > >>>>>>>>>>>
> > >>>>>>>>>>> java.nio.file.Path is not Serializable!
> > >>>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>> What am I doing wrong?
> > >>>>>>>>>>
> > >>>>>>>>>>> [1] https://github.com/apache/openmeetings/commit/
> > >>>>>>>>>>> 5fa2c87f212e4eecdd1368f2ae7fa8762832838f#diff-
> > >>>>>>>>>>> 0a499c88998a93ceb51c347836aa6195R115
> > >>>>>>>>>>>
> > >>>>>>>>>>> On Thu, Mar 23, 2017 at 3:16 AM, Martin Grigorov
> > >>>>>>>>>>> <mgrigorov@apache.org
> > >>>>>>>>>>> wrote:
> > >>>>>>>>>>>
> > >>>>>>>>>>> On Wed, Mar 22, 2017 at 12:59 PM, Maxim Solodovnik <
> > >>>>>>>>>>>> solomax666@gmail.com
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> wrote:
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> Actually I have 2 example use cases:
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>> 1) user selects files on file tree
> > >>>>>>>>>>>>> 2) as soon as file is selected and download is enabled for
> > it,
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>> used
> > >>>>
> > >>>>> can
> > >>>>>>>>>>>>> press ajax download button and get the file
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>>> Another case:
> > >>>>>>>>>>>>> User requests system backup
> > >>>>>>>>>>>>> As soon as backup is created (Progress complete)
> > >>>>>>>>>>>>> Download of newly created file should be initiated
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>>> I can't create ResourceReference and override
> > getResourceStream
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>> of
> > >>>>
> > >>>>> it
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>>> since
> > >>>>>>>>>>>> I only have resource just before download
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>> Wicket IResource is an abstraction over the real resource.
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>> In my case i also create the response on the fly. It is
> > either a
> > >>>>>>>>>>>> single
> > >>>>>>>>>>>> File or a Zip file with several entries.
> > >>>>>>>>>>>> The ResourceReference is more or less just an endpoint with
> > >>>>>>>>>>>> almost
> > >>>>>>>>>>>> no
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> logic
> > >>>>>>>>>>>
> > >>>>>>>>>>> at all. It just creates the IResource.
> > >>>>>>>>>>>> The IResource uses the information from the request
> > parameters /
> > >>>>>>>>>>>> session
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> /
> > >>>>>>>>>>>
> > >>>>>>>>>>> somewhere else to create the actual response (the files).
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> AjaxDownload is an Ajax behavior that you can use to trigger
> > the
> > >>>>>>>>>>>> creation
> > >>>>>>>>>>>> of the files and by using its callback methods you can show
> > >>>>>>>>>>>>
> > >>>>>>>>>>> feedback
> > >>>>
> > >>>>> to
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> the
> > >>>>>>>>>>>
> > >>>>>>>>>>> user. To show progress bar you will need to employ
> ProgressBar
> > >>>>>>>>>>>>
> > >>>>>>>>>>> from
> > >>>>
> > >>>>> wicket-extentions or use WebSockets.
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> On Wed, Mar 22, 2017 at 6:53 PM, Martin Grigorov <
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>> mgrigorov@apache.org>
> > >>>>>>>>>>>>> wrote:
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>>> Hi Maxim,
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>>>> I use the new AjaxDownload with a ResourceReference, i.e.
> > >>>>>>>>>>>>>> AjaxDownload#AjaxDownload(org.apache.wicket.request.
> > >>>>>>>>>>>>>> resource.ResourceReference,
> > >>>>>>>>>>>>>> org.apache.wicket.request.mapper.parameter.
> PageParameters)
> > >>>>>>>>>>>>>> The ResourceReference has
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>>> public IResource getResource() {
> > >>>>>>>>>>>>>>        return new StatementDownloadResource();
> > >>>>>>>>>>>>>> }
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>>> StatementDownloadResource extends ResourceStreamResource
> and
> > >>>>>>>>>>>>>> provides
> > >>>>>>>>>>>>>> implementation of #getResourceStream(). There I have a
> logic
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>> that
> > >>>>
> > >>>>> returns
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>> either FileResourceStream or ZipResourceStream.
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>> Martin Grigorov
> > >>>>>>>>>>>>>> Wicket Training and Consulting
> > >>>>>>>>>>>>>> https://twitter.com/mtgrigorov
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>>> On Wed, Mar 22, 2017 at 12:30 PM, Maxim Solodovnik <
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>>> solomax666@gmail.com
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>> wrote:
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>> Just have tried to switch to this AjaxDownload component
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>> And it seems I cannot find proper way to use it with
> > dynamic
> > >>>>>>>>>>>>>>> file,
> > >>>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>> i.e.
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>> previously
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>> I created AjaxDownload,
> > >>>>>>>>>>>>>>> added it to the page
> > >>>>>>>>>>>>>>> then at the moment I know what file should be served, I
> set
> > >>>>>>>>>>>>>>> the
> > >>>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>> stream
> > >>>>>>>>>>>>>>
> > >>>>>>>>>>>>> and
> > >>>>>>>>>>>>
> > >>>>>>>>>>>>> initiate the download
> > >>>>>>>>>>>>>>> (for example one of use cases: I need to create zip file
> > >>>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>> right now this seems to be impossible :(
> > >>>>>>>>>>>>>>> Can you give me a hint how this dynamic nature can be
> > >>>>>>>>>>>>>>> implemented?
> > >>>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>> --
> > >>>>>>>>>>>>>>> WBR
> > >>>>>>>>>>>>>>> Maxim aka solomax
> > >>>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>>
> > >>>>>>>>>>>>>>> --
> > >>>>>>>>>>>>> WBR
> > >>>>>>>>>>>>> Maxim aka solomax
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>>>
> > >>>>>>>>>>>>> --
> > >>>>>>>>>>> WBR
> > >>>>>>>>>>> Maxim aka solomax
> > >>>>>>>>>>>
> > >>>>>>>>>>>
> > >>>>>>>>>>> --
> > >>>>>>>>> WBR
> > >>>>>>>>> Maxim aka solomax
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>
> > >>>>
> > >>>> --
> > >>>> WBR
> > >>>> Maxim aka solomax
> > >>>>
> > >>>>
> > >>
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>