Open/Save file from web client

Forum to discuss the Web client version of Servoy.

Postby Westy » Thu Dec 21, 2006 4:34 pm

pbakker wrote:In the latest 3.1 beta's more functionality has been added, so if you have a global containing a file, you can use that as well, you can set the mime-type and filename as well.

Thank you for pointing this out and for the nice example of this great new feature!

Dean
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Postby martinh » Mon Jun 09, 2008 3:06 pm

Can someone see what is wrong with the following line.
I think I do like expected, but for some reason I don't see the correct image:

This is my code:

Code: Select all
if (_to_webshop.button_image_add_to_cart)
   elements.btn_add_to_cart.setImageURL('media:///servoy_blobloader?servername='+ _to_webshop.getServerName()+'&tablename='+ _to_webshop.getTableName()+'&dataprovider=button_image_add_to_cart&webshop_id=' + _to_webshop.webshop_id + '&mimetype=image/png');


The relation _to_webshop points to 1 single record.
When I do _to_webshop.getSize() I get 1 as result

I've put the same line as application.output and I see the following:

Code: Select all
media:///servoy_blobloader?servername=myServer&tablename=webshop&dataprovider=button_image_add_to_cart&webshop_id=f7fb71a2-b8fb-4b97-9a17-087042dd642b&mimetype=image/png

That looks correct. It is also the correct webshop_id

But the image I see is from another record (first record) in the webshop table.

I also tried to replace 'webshop_id=' by 'rowid1=', but that doesn't change anything.

Does someone see in the coding line what is wrong?
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Postby martinh » Mon Jun 09, 2008 4:55 pm

I tried all kind of combinations.

The following is working:

Code: Select all
elements.btn_add_to_cart.setImageURL('media:///servoy_blobloader?servername='+ _to_webshop.getServerName()+'&tablename='+ _to_webshop.getTableName()+'&dataprovider=button_image_add_to_cart&rowid1=' + _to_webshop.webshop_id + '&mimetype=image/png');


Important is also not to put double quotes around the value (so not rowid1="f7fb71a2-b8fb-4b97-9a17-087042dd642b", which I tried before)

Wouldn't it be more logic to use the real columnname in stead of rowid1?
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Postby martinh » Tue Jun 10, 2008 11:02 am

Unfortunately I was too early happy.

It works perfect in Smart client but not at all in webclient

I made an example solution.
I hope that Support can see what is wrong

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re:

Postby Westy » Wed Oct 08, 2008 7:35 pm

pbakker wrote:Search the forum, I'd say... :D

But with the BlobLoader you can extract files from the DB or globals and use them in the same way as you would use files from Servoys media library inside HTML.

In the latest 3.1 beta's more functionality has been added, so if you have a global containing a file, you can use that as well, you can set the mime-type and filename as well.

for example, if you create a calculation with the following code, and place a HTML Area on your form with the Calc as DataProvider, then, in the WebClient, clicking the link would open the file.

Code: Select all
var URL = 'media:///servoy_blobloader?servername=' + currentcontroller.getServerName() + '&tablename=XXXXX&dataprovider=YYYYY&rowid1=' + ZZZZZ+'&mimetype='+AAAAA+'&filename='+BBBBBB
   return '<html><body><a target="_blank" href="'+URL+'">test</a></body></html>';


Where:
- XXXXX is the name of the table your file is stored in
- YYYYYY is the columnname of the column where the file is stored
- ZZZZZ is value of the PK field of the row (In case of a PK buildup out of multiple columns, add &rowid2=value ... &rowidXX=value)
- AAAAA is the mimetype of the file
- BBBBB is the name of the file

Regards,

Paul


What is the syntax for using with a global media field?
What is the syntax for using with a application.showURL?

The above example worked perfectly, but I am having trouble getting it to work while using with a global and with show URL.

Dean Westover
Choices Software, Inc.
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: Open/Save file from web client

Postby Infop » Thu Oct 30, 2008 12:18 pm

Hi all,

What should I do, if I want to open a (save/open)FileDialog in WebClient just like same as rich client. If it is a media field, then it will shows the option to open the file dialog. If I am explicitly want to show a file dialog, such as on clicking of a button, then what should I do??

saveFileDialog() will let the user to save the file on the client's system.

Thanks in advance.
User avatar
Infop
 
Posts: 151
Joined: Fri Nov 30, 2007 3:00 pm

Re: Open/Save file from web client

Postby jcompagner » Thu Nov 27, 2008 3:40 pm

to save a file (open a file save dialog) you just have to stream something (clicking on a link) to the browser then the browser will popup that
You cant ask for that to happen without that stream

to load a file this is also not possible by just an button you have to use the the input type = file for that else a browser wont allow you to do that.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8836
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Open/Save file from web client

Postby Westy » Sat Nov 29, 2008 12:00 am

I still have not been able to get the above to work while using with a global and with show URL. I just need to save a file to a global field and then open it using a URL. Does anyone have example code showing how this can be done?

Dean Westover
Choices Software, Inc.
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: Open/Save file from web client

Postby jcompagner » Wed Dec 03, 2008 1:58 pm

the global is a media field?

then if you display it as a Media field then a user can upload a file (or save a file)
then i guess if you want to do something with it you can store it somewhere on the server and generate an url to it

(you have to store it in webapps\root dir)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8836
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Open/Save file from web client

Postby martinh » Mon Dec 08, 2008 5:34 pm

Johan,

Can you make it for us much more easier. It looks we all have the same problem, but I haven't seen a simple solution.
If I can remember well, I've seen in the past replies on the forum that upload/download files from the server when using webclient will be made much more easier, but it looks it hasn't been realized yet.
More and more we want webclient solutions, but uploading a file to the server using a webclient still remains a problem.

Also for the download the solutions I've seen can work but I don't see the perfect solution. When using the blobloader, you immediately have the data in the client and that doesn't seem good solution as well. And using a .jsp page together with a headless client is not an easy solution as well.

Can you create some method which looks like the following:

boolean uploadFile(<sourcefile on localdisk>, <destination field in database> || <destination path on server disk>)

Otherwise perhaps you can restyle the svyDoc sample solution so that it also works in webclient. Then everyone can see how you guys at Servoy handle such a problem.


Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Open/Save file from web client

Postby martinh » Mon Dec 08, 2008 5:49 pm

Johan,

In the support system I see a pop-up window for browse and upload:

Code: Select all
<form id="id9c" method="post" action="?x=nijmbISW*CiLQnSZCRnMstunwCVTjjZ7" enctype="multipart/form-data"><div style="display:none"><input type="hidden" name="id9c_hf_0" id="id9c_hf_0" /></div>
<fieldset>
<legend>Upload form</legend>
<p>
<label for="upload">File</label>
<input id="upload" type="file" name="fileupload"/>&nbsp;<input type="submit" value="Upload"/>

</p>
</fieldset>
</form>


What scripting do you have behind action="?x=nijmbISW*CiLQnSZCRnMstunwCVTjjZ7" ?

How can you retrieve the file in script, without using a separate jsp page to handle the form submit?

And is this form a Servoy form or is this a runtime generated form?

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Open/Save file from web client

Postby jcompagner » Mon Dec 08, 2008 7:01 pm

that what you see in the support system is just a media field!

Thats just how it works, you upload (or download) to (or from) a mediafield.

To retrieve the file is still something on the todo, you just have a mediafield column and 2 other columns mediafield_filename and mediafield_mimetype
where we then store the names

something like this:

boolean uploadFile(<sourcefile on localdisk>, <destination field in database> || <destination path on server disk>)


is impossible, that is not allowed in the web. For that just dont use a browser use a smart client then you have all the power and you are not limited by anything.

uploading a file has to go over a:

<input id="upload" type="file" name="fileupload"/>

and you dont control the sourcefile name at all. that something a user has to pick by clicking on the browse button.

I guess somebody could make a WebFile plugin/bean or something that generates such a input (type=file) as above on your web page
and that will handle the upload and then you can ask it things like:

bean.getData()
bean.getFileName()

johan
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8836
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Open/Save file from web client

Postby IT2Be » Tue Dec 09, 2008 1:25 am

Maybe the DataStream plug-in should do that.
It is already perfect for streaming data :)
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Re: Open/Save file from web client

Postby martinh » Tue Dec 09, 2008 10:17 am

jcompagner wrote:that what you see in the support system is just a media field!

Thats just how it works, you upload (or download) to (or from) a mediafield.

To retrieve the file is still something on the todo, you just have a mediafield column and 2 other columns mediafield_filename and mediafield_mimetype
where we then store the names



Johan,

I do not understand how I can realize this with these media fields.
Can you be more specific.

Please let me/us know what is done exactly in the support system when pressing the upload button

Martin
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: Open/Save file from web client

Postby pbakker » Tue Dec 09, 2008 10:33 am

Martin,

If you place a field with a dataprovider of type "media" on a form and you show it in the webClient, when the field is editable it will automatically get those extra buttons to upload/save/delete the content of the media field.

Browsers in general have the restriction that if you want to upload a file, the user has to select 1 specific file manually from their local filesystem. This is a browser restriction, not something we can influence at all.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

PreviousNext

Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 3 guests

cron