Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » using HTML.imgByBinaryResource with Image from database(Image HTML.imgByBinaryResource())
using HTML.imgByBinaryResource with Image from database [message #1826237] Tue, 21 April 2020 16:40 Go to next message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
Hello,
I would like to create an image in a tile from a database, I am getting the image as a BinaryResource but the tag HTML.imgByBinaryResource() does not accept binary data.
How to cache image and pass it to HTML.imgByBinaryResource.
Regards
Re: using HTML.imgByBinaryResource with Image from database [message #1826253 is a reply to message #1826237] Wed, 22 April 2020 08:18 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
I guess the simplest approach is to use the org.eclipse.scout.rt.client.ui.tile.fields.AbstractImageFieldTile, which is a tile that has an AbstractImageField. Here's a code example:

            @Order(90)
            @ClassId("e5ad2df0-f2e8-4f30-8760-e17596c740dc")
            public class TestImageTile extends AbstractImageFieldTile {

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

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

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


In this example we create a BinaryResource from a resource which is on the classpath. In your case you could simply use the BinaryResource you've read from the database.


Eclipse Scout Homepage | Documentation | GitHub
Re: using HTML.imgByBinaryResource with Image from database [message #1826258 is a reply to message #1826253] Wed, 22 April 2020 10:05 Go to previous messageGo to next message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
Hello,
I used the code in execCreateTile like this

@Override
protected ITile execCreateTile(ITableRow row) {

return new AbstractImageFieldTile() {

@Override
protected String getConfiguredLabel() {
return row.getCell(getGroupNameColumn()).getValue().toString();
}

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



@Override
protected void execLoadData() {
getTileWidget().setLabelVisible(false);

Integer group_id = (Integer) row.getCell(getGroupIDColumn().getColumnIndex())
.getValue();
IWorkingToolService service = BEANS.get(IWorkingToolService.class);
BinaryResource groupImg = service.getGroupImage(group_id);
if (groupImg.getContent() != null) {
getTileWidget().setImage(groupImg);
getTileWidget().setAutoFit(true);
GridData gdh = getTileWidget().getGridDataHints();
gdh.horizontalAlignment = -1;
getTileWidget().setGridDataHints(gdh);
}

}
};
}

but the execLoadData is not been executed, it does not go into that code. am I missing something else ?
Re: using HTML.imgByBinaryResource with Image from database [message #1826282 is a reply to message #1826258] Wed, 22 April 2020 18:24 Go to previous message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
I solved the issue using an other method by creating an instance of AbstractImageFieldTile then modifiying the image like this tile.getTileWidget().setImage(groupImg);
thanks
Previous Topic:how to capture content in ImageField using uploadEnabled
Next Topic:Exporting table to Excel in scout 10
Goto Forum:
  


Current Time: Thu Apr 25 19:24:23 GMT 2024

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

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

Back to the top