Not able to upload [a Seaside.WAFile] through onClick

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Not able to upload [a Seaside.WAFile] through onClick

dirk newbold
Hi All,
 
I have been trying to upload a picture through the onClick callback and where I would usually use:
 
 html form
  multipart;
  with: [
   html fileUpload callback: [:f | file := f].
   html submitButton text: 'Load'].
 
I have been trying the following as it worked for all the other form elements i.e. input, select etc:
 
 html form
  multipart;
  id: 'fid';
  with: [
   html fileUpload callback: [ :f | file:= f ].
   html submitButton
     onClick: (html updater
       id: 'pictureHolder';
       triggerForm: 'fid';
       callback: [ :r | self renderPicture: r ];
       return: false);
   text: 'Save' ]
 
But instead of returning  "a Seaside.WAFile" it is returning the directory path.
Any ideas?
 
Cheers,
 
Dirk

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Not able to upload [a Seaside.WAFile] through onClick

Lukas Renggli
> But instead of returning  "a Seaside.WAFile" it is returning the directory
> path.

File-upload do not work through XmlHttpRequest due to security
restrictions in the web-browser.

The easiest solution is to have a separate form around the upload
field and commit the whole form. Something along ...

html form id: 'fileupload'; multipart; with: [
   html fileUpload
      callback: [ :file | ... ];
      onChange: (SUForm new
         id: 'fileupload';
         submit) ]

If you want to go the AJAX way you have to do some nasty tricks using
IFRAMES to push the data to the server. This is also what GMail is
doing for their file uploads for example.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Not able to upload [a Seaside.WAFile] through onClick

dirk newbold
Cheers, I'll give it a go

On 9/19/07, Lukas Renggli <[hidden email]> wrote:
> But instead of returning  "a Seaside.WAFile" it is returning the directory
> path.

File-upload do not work through XmlHttpRequest due to security
restrictions in the web-browser.

The easiest solution is to have a separate form around the upload
field and commit the whole form. Something along ...

html form id: 'fileupload'; multipart; with: [
  html fileUpload
     callback: [ :file | ... ];
     onChange: (SUForm new
        id: 'fileupload';
        submit) ]

If you want to go the AJAX way you have to do some nasty tricks using
IFRAMES to push the data to the server. This is also what GMail is
doing for their file uploads for example.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Not able to upload [a Seaside.WAFile] through onClick

Andrius Paulavicius
use an hidden iframe for forms target

html iframe name: 'uiframe'.

html form
    attributeAt: 'target' put: 'uiframe';
    ...

----- Original Message -----
From: dirk newbold
To: Seaside - general discussion
Sent: Thursday, September 20, 2007 1:03 AM
Subject: Re: [Seaside] Not able to upload [a Seaside.WAFile] through onClick


Cheers, I'll give it a go


On 9/19/07, Lukas Renggli <[hidden email]> wrote:
> But instead of returning  "a Seaside.WAFile" it is returning the directory
> path.

File-upload do not work through XmlHttpRequest due to security
restrictions in the web-browser.

The easiest solution is to have a separate form around the upload
field and commit the whole form. Something along ...

html form id: 'fileupload'; multipart; with: [
  html fileUpload
     callback: [ :file | ... ];
     onChange: (SUForm new
        id: 'fileupload';
        submit) ]

If you want to go the AJAX way you have to do some nasty tricks using
IFRAMES to push the data to the server. This is also what GMail is
doing for their file uploads for example.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Not able to upload [a Seaside.WAFile] through onClick

dirk newbold
I think I'm batting out of my league here but I'm keen to learn.
 
How would I implement Andrius's code?
 
Below is my attempt to implement Lukas's code but it is not recognising submit, any ideas?
 
Cheers,
 
Dirk
 
 html form multipart; id: 'pictureUpload'; with: [
  html form id: 'fileupload'; multipart; with: [
   html fileUpload
    callback: [ : val | self product picture1: val ];
    onChange: (Seaside.SUForm new id: 'fileupload'; submit )].
  html submitButton
   onClick: (html updater
    id: 'uploadProductPictures';
    triggerForm: 'pictureUpload';
    callback: [ :r | self renderUploadPictures: r ];
    return: false);
   text: 'Save' ]

 
On 9/20/07, Andrius Paulavicius <[hidden email]> wrote:
use an hidden iframe for forms target

html iframe name: 'uiframe'.

html form
   attributeAt: 'target' put: 'uiframe';
   ...

----- Original Message -----
From: dirk newbold
To: Seaside - general discussion
Sent: Thursday, September 20, 2007 1:03 AM
Subject: Re: [Seaside] Not able to upload [a Seaside.WAFile] through onClick


Cheers, I'll give it a go


On 9/19/07, Lukas Renggli <[hidden email]> wrote:
> But instead of returning  "a Seaside.WAFile" it is returning the directory
> path.

File-upload do not work through XmlHttpRequest due to security
restrictions in the web-browser.

The easiest solution is to have a separate form around the upload
field and commit the whole form. Something along ...

html form id: 'fileupload'; multipart; with: [
html fileUpload
    callback: [ :file | ... ];
    onChange: (SUForm new
       id: 'fileupload';
       submit) ]

If you want to go the AJAX way you have to do some nasty tricks using
IFRAMES to push the data to the server. This is also what GMail is
doing for their file uploads for example.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Not able to upload [a Seaside.WAFile] through onClick

Lukas Renggli
> Below is my attempt to implement Lukas's code but it is not recognising
> submit, any ideas?

1. Do never nest forms. This won't work and will lead to all kind of
strange problems (different ones in different browsers).

2. You don't need the submit button, as the form is automatically
submitted when the user selects a file. This automatically causes a
full refresh.

> How would I implement Andrius's code?

This involves some JavaScript programming, that is actually very
similar to the code used in the (totally unrelated) Comet package.

1. You create a named IFRAME that you hide somewhere on your page
(move it somewhere outside the visible viewport, fully hiding the
thing breaks some browsers).

2. You assign an onLoad event to the IFRAME that updates the part of
the page after the successful upload.

3. As presented you set the target of your form to the IFRAME.
Combined with the #onChange: on the file-upload you don't even need a
submit button.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Not able to upload [a Seaside.WAFile] through onClick

Andrius Paulavicius
I just do something like:

    html iframe name: 'fileupload';
    html form
        attributeAt: 'target' put: 'fileupload';
        multipart;
        with: [
            html fileUpload callback: [:f | file := f].
            html submitButton
            onClick: (html evaluator callback:  [:script |
                self validateFile.
                self updateErrorMesage: script]);
        text: 'upload'].

I hide the iframe by setting its style to
    height: 0;
    width: 0;
    border-style: none;

doe's uploading without refreshing the rest of the page and seems to work
in both firefox and ie
 
----- Original Message -----
From: "Lukas Renggli" <[hidden email]>
To: "Seaside - general discussion" <[hidden email]>
Sent: Thursday, September 20, 2007 11:43 AM
Subject: Re: [Seaside] Not able to upload [a Seaside.WAFile] through onClick


>> Below is my attempt to implement Lukas's code but it is not recognising
>> submit, any ideas?
>
> 1. Do never nest forms. This won't work and will lead to all kind of
> strange problems (different ones in different browsers).
>
> 2. You don't need the submit button, as the form is automatically
> submitted when the user selects a file. This automatically causes a
> full refresh.
>
>> How would I implement Andrius's code?
>
> This involves some JavaScript programming, that is actually very
> similar to the code used in the (totally unrelated) Comet package.
>
> 1. You create a named IFRAME that you hide somewhere on your page
> (move it somewhere outside the visible viewport, fully hiding the
> thing breaks some browsers).
>
> 2. You assign an onLoad event to the IFRAME that updates the part of
> the page after the successful upload.
>
> 3. As presented you set the target of your form to the IFRAME.
> Combined with the #onChange: on the file-upload you don't even need a
> submit button.
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Not able to upload [a Seaside.WAFile] through onClick

dirk newbold
Thanks for the help.
 
Cheers,
 
Dirk

 
On 9/20/07, Andrius Paulavicius <[hidden email]> wrote:
I just do something like:

   html iframe name: 'fileupload';
   html form
       attributeAt: 'target' put: 'fileupload';
       multipart;
       with: [
           html fileUpload callback: [:f | file := f].
           html submitButton
           onClick: (html evaluator callback:  [:script |
               self validateFile.
               self updateErrorMesage: script]);
       text: 'upload'].

I hide the iframe by setting its style to
   height: 0;
   width: 0;
   border-style: none;

doe's uploading without refreshing the rest of the page and seems to work
in both firefox and ie

----- Original Message -----
From: "Lukas Renggli" <[hidden email]>
To: "Seaside - general discussion" <[hidden email]>
Sent: Thursday, September 20, 2007 11:43 AM
Subject: Re: [Seaside] Not able to upload [a Seaside.WAFile] through onClick


>> Below is my attempt to implement Lukas's code but it is not recognising
>> submit, any ideas?
>
> 1. Do never nest forms. This won't work and will lead to all kind of
> strange problems (different ones in different browsers).
>
> 2. You don't need the submit button, as the form is automatically
> submitted when the user selects a file. This automatically causes a
> full refresh.
>
>> How would I implement Andrius's code?
>
> This involves some JavaScript programming, that is actually very
> similar to the code used in the (totally unrelated) Comet package.
>
> 1. You create a named IFRAME that you hide somewhere on your page
> (move it somewhere outside the visible viewport, fully hiding the
> thing breaks some browsers).
>
> 2. You assign an onLoad event to the IFRAME that updates the part of
> the page after the successful upload.
>
> 3. As presented you set the target of your form to the IFRAME.
> Combined with the #onChange: on the file-upload you don't even need a
> submit button.
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside