Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » How to display an image from data base into a HTML Field
How to display an image from data base into a HTML Field [message #1844335] Thu, 09 September 2021 17:07 Go to next message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
Hello
I need to display an image inside a html filed, How can I do that when I fetch the image from database and it does not exist under icons folder, the HTML.getimageByBinaryResource( CharSequence s ) does not provide a solution for this and I think the name is incorrect here We dont pass a binary resource but a charsequence.
Is there any solution with the Eclipse scout SDK 11.
Kind Regards
Re: How to display an image from data base into a HTML Field [message #1844336 is a reply to message #1844335] Thu, 09 September 2021 17:17 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
You might be able to call the addAttachment(...)/(setAttachments(...) method on the HTML field with the binary resources which actually contain the images and afterwards you can use them with <img src="binaryresource:file_name_of_binary_resource.jpg, see https://eclipsescout.github.io/5.2/latest/scout_migration/scout_migration/scout_migration_guide.html#html-field - this migration guide however describes a much older version of Scout, I am not sure if everything is still the same with the current version.
Re: How to display an image from data base into a HTML Field [message #1844337 is a reply to message #1844336] Thu, 09 September 2021 17:33 Go to previous messageGo to next message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
For information, I used the code in an other thread and it is not working
is was recommended to use AbstractImageTile instead

The goal is the create image insode tiles when switch to tile mode in table

@Override
protected ITile execCreateTile(ITableRow row) {

BinaryResource img = BEANS.get(IMyService.class).getMYImage(id);

AbstractImageFieldTile imageFieldTile = new AbstractImageFieldTile() {

@Override
protected String getConfiguredLabel() {
return "Label";
}

@Override
protected int getConfiguredGridH() {
return 2;
}

@Override
protected void execLoadData() {
getTileWidget().setLabelVisible(false);
if (img != null)
getTileWidget().setImage(img);
else
try (InputStream in = ResourceBase.class.getResourceAsStream("images/not_found.png")) {
getTileWidget().setImage(new BinaryResource("not_found.png", IOUtility.readBytes(in)));
} catch (IOException e) {
throw new ProcessingException("resource", e);
}
getTileWidget().setAutoFit(true);
GridData gdh = getTileWidget().getGridDataHints();
gdh.horizontalAlignment = -1;
getTileWidget().setGridDataHints(gdh);
}

};

return imageFieldTile;

}

This is not working in case of table
Re: How to display an image from data base into a HTML Field [message #1844532 is a reply to message #1844337] Thu, 16 September 2021 06:41 Go to previous message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
Hello
That works perfectly with attachement, It was a great hint from you , thank you :)
Kind Regards
Previous Topic:InteliJ Hello World Production Error 404
Next Topic:It is possible to implement an offline client Session with Scout
Goto Forum:
  


Current Time: Wed May 08 22:07:00 GMT 2024

Powered by FUDForum. Page generated in 0.03609 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top