Is it possible to insert pictures from database in HTML?

You can insert images stored inside the solution into HTML using the

<img src = "media:///imagename.gif">

syntax.

I’m using databaseManager.getDataSetByQuery() to extract data from the database following the example outlined in
http://forum.servoy.com/viewtopic.php?p … ight=#8635

Is there any way of displaying images from a normal database field?

We are thinking about providing something like:
media:///servoy_blobloader?servername=&tablename=&dataprovider=&rowid1=
In Servoy 2.1, seems to us the most easy way to do this…

This would be VERY cool Jan. Are we moving away from a forms based development environment here? :)

  • David

david:
Are we moving away from a forms based development environment here?

Very dynamic UI’s cannot be easily done with forms… so we understand the need for this, and it 2 way, the form can generate a dynamic UI part with form method callbacks when a link is clicked.

Do I understand correctly that in the future it will also be possible to create input forms with HTML (with buttons, comboboxes etc) and feed back the variables from the HTML back to Servoy methods?

If so, that would be very cool…

Paul

We did not think about forms yet, but this is possible:

<a href="javascript:formMethodNameToExecute(2,4,'blabla')"><img src="media:///buttonimage.gif"></a>

yep, using at allready, but my problem lies in passing variables back… For example, in the HTML field, I can create a combobox with an x amount of values. The user can select a value from the combobox, but I cannot get that value back into Servoy

Paul

Is there any news on this:

We are thinking about providing something like:
media:///servoy_blobloader?servername=&tablename=&dataprovider=&rowid1=

I am just trying to build a value list with picture and name coming from a table. I am trying to build a html table for every record and now come accross the issue of how to get hold of my image.

Thanks
Patrick

yes, that works since Servoy 2.1 beta4

I am trying this in a calculation:

var html = '<html><table border="0" cellspacing="0" cellpadding="0"><tr><td width="25" valign="middle"><img src="' + 'media:///servoy_blobloader?servername=server&tablename=table&dataprovider=image&rowid1= ' + pk_table + '" border="0"></td><td valign="middle">' + land + '</td></tr></table></html>'

Is this supposed to work (it doesn’t in my case)?

you have to specify the parameters for servername ,tablename and dataprovider name.
example:
media:///servoy_blobloader?servername=crm_server&tablename=employees&dataprovider=headfoto&rowid1=10244

of course, I did that. I just anonimized my example. It still doesn’t retrieve a picture…

  1. is the picture of type gif/jpg/png?
  2. are you sure that row has a picture?

If both questions result in true, please sent us a sample solution with some sample data to demonstrate the problem.

  1. I think it was a gif. Now it is stored in the database.
  2. Yes, I am sure. I have the same picture placed directly on the form and see it…

I am still not able to get this to work. I have tried to things:

  1. a calculation
var image = 'media:///servoy_blobloader?servername=spotlight&tablename=v_laender&dataprovider=flagge_klein&rowid1=' + uid_land
return image;
  1. a calculation that uses an image that is supposed to be retrieved like 1. in HTML

What am I missing?

This works ok for me:

elements.blob_url_display.setImageURL('media:///servoy_blobloader?servername='+controller.getServerName()+'&tablename='+controller.getTableName()+'&dataprovider=img&mimetype=image/gif&rowid1=1');

the same url syntax can be used in html.

A method, that sets a label, works for me, too:

var image = 'media:///servoy_blobloader?servername=' + currentcontroller.getServerName() + '&tablename=v_laender&dataprovider=flagge_klein&mimetype=image/gif&rowid1=' + uid_v_laender
elements.bild.setImageURL(image);

What doesn’t work, is to use this in a calculation where either the image is returned (in a media calculation) or returned nested in HTML.

For the calculation I am using the exact same code as above, but I return “image” in case of the media calculation.

Loading in html seems no problem for me:

elements.blob_url_display.text =  '<html><img src="media:///servoy_blobloader?servername='+controller.getServerName()+
'&tablename='+controller.getTableName()+
'&dataprovider=img&mimetype=image/gif&rowid1=1"></html>';

What you are trying todo with the media field I don’t understand you are loading the url text in a media field? (which only support byte array’s).
It seems to me you are trying to use the media field in the wrong way

We are having communication troubles…

Let’s try it this way:

What I want to do is a value list which shows icon and text in the popup. I have done those before with html by hand. Each entry is a table with one row and three columns: icon, spacer, text.

Now I want to use the new functionality to do a value list like that based on a table. I have a table with countries and their flags. So I thought I create a calculation (stored) in that table that throws me the html code for one entry and I could then build a value list on that column.

How do I have to go about this?

  1. make a dbvaluelist on columns (language_id,stored_calc_flag_language)
  2. let stored_calc_flag_name return: ```
    - ‘+language_name+’’