[Gambas-user] Help for gb.web.gui

Benoit Minisini benoit.minisini at gambas-basic.org
Wed Aug 10 11:54:56 CEST 2022


Le 07/08/2022 à 22:43, T Lee Davidson a écrit :
> On 8/7/22 16:29, gian via User wrote:
>> Hi,
>>
>> There is a friend from the Italian forum, who starting from the 
>> sources of the farm WebDemo program, try with this simple attached 
>> test generate with the server a CSV file, this works, then he would 
>> like from browser see download and save the file in the download 
>> folder, this does not happen.
>>
>> Can you help him? Thank you
>>
>> With best regards
>>
>> Gianluigi
> 
> I think there is a bug in the lib.js file that gb.web.gui uses. I am 
> using stable Gambas 3.17.3, and I see that lib.js is different in the 
> developer branch at the very spot where my browser developer console 
> reports a Syntax Error in that file:
> Uncaught SyntaxError: unexpected token: ':' lib:0.0.1.js:1:19
>      answer http://localhost:8080/lib:0.0.1.js:275
>      onreadystatechange http://localhost:8080/lib:0.0.1.js:324
>      sendNewCommand http://localhost:8080/lib:0.0.1.js:324
>      answer http://localhost:8080/lib:0.0.1.js:295
>      onreadystatechange http://localhost:8080/lib:0.0.1.js:324
>      sendNewCommand http://localhost:8080/lib:0.0.1.js:324
>      send http://localhost:8080/lib:0.0.1.js:345
>      update http://localhost:8080/lib:0.0.1.js:355
>      onFocus http://localhost:8080/lib:0.0.1.js:431
>      answer http://localhost:8080/lib:0.0.1.js:275
>      onreadystatechange http://localhost:8080/lib:0.0.1.js:324
>      (Async: EventHandlerNonNull)
>      sendNewCommand http://localhost:8080/lib:0.0.1.js:324
>      answer http://localhost:8080/lib:0.0.1.js:295
>      onreadystatechange http://localhost:8080/lib:0.0.1.js:324
>      (Async: EventHandlerNonNull)
>      sendNewCommand http://localhost:8080/lib:0.0.1.js:324
>      send http://localhost:8080/lib:0.0.1.js:345
>      update http://localhost:8080/lib:0.0.1.js:355
>      onFocus http://localhost:8080/lib:0.0.1.js:431
> 
> 
> Benoît, have you fixed this already?
> 
> 

OK, this is not a bug, but the code that is flawed.

Your friend thought that a file can be sent from the server to the 
client by using 'Response.SendFile()' inside an event handler.

1) First mistake: a file download is initiated by the client, never by 
the server.

2) Second mistake: 'Response.SendFile()' works only if the client 
initiated a download request, i.e. if it expects that kind of answer. 
This is not the case when you are running an event handler in 
'gb.web.gui', where the communication follows a specific protocol, that 
you can't hijack with lower level functions like 'Response.Send()'.

Regards,

-- 
Benoît Minisini.


More information about the User mailing list