Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » displaying images not from the default directory
displaying images not from the default directory [message #1807092] Wed, 22 May 2019 12:57 Go to next message
Krzysztof Leja is currently offline Krzysztof LejaFriend
Messages: 26
Registered: April 2019
Junior Member
I would like to add a lot of images to my application and for better clarity and order, I would like to store each group of images in an independent sub-directory.
Thus, for example: in the default directory /org/eclipse/scout/apps/myapp/client/icons in the "src/main/resources" folder of the * .client module I created a new sub-directory called flags, where I saved some of the images. To display one of them (flag1.jpg) I used this code:
                  public class FlagImageField extends AbstractImageField {
				protected String getConfiguredImageId() {
					return "flags/flag1";
				protected String getConfiguredLabel() {
					return "Country";
				protected byte getConfiguredLabelPosition() {

				protected int getConfiguredGridH() {
					return 4;

However, it does not work. The image is not displayed.
I did debugging the DefaultIconProviderService class, which I did not change compared to the default implementation as follows:
public class DefaultIconProviderService extends AbstractIconProviderService {
	protected URL findResource(String relativePath) {
		return ResourceBase.class.getResource("icons/" + relativePath);

I see that the Scout Platform calls above findResource method for the relativePath = "flags/flag1.jpg" parameter and finds the resource.

So where is the catch? What am I doing wrong?
Re: displaying images not from the default directory [message #1807119 is a reply to message #1807092] Thu, 23 May 2019 07:23 Go to previous message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 66
Registered: September 2012
Location: Baden-D├Ąttwil, Switzerla...
Hi Krzysztof
Thanks for debugging and reporting that issue here. It seems like you have found a bug in the JSON layer of Scout. When Scout requests an icon via HTTP, the request URL looks like this:

The request is handled by the class IconLoader where the following happens:
final String imageId = pathInfo.substring(pathInfo.lastIndexOf('/') + 1);

Which means only the last part of the URL "flag1.jpg" is used to lookup the icon in the IconProviderService. Could you please report that bug in our Bugzilla?

Until the bug is fixed in Scout you cannot use sub-directories in the /icons folder.

As a workaround you could use the execInit() method instead of getConfiguredImageId(), load the icon and set it as image (BinaryResource):

        protected void execInitField() {
          IconSpec iconSpec = IconLocator.instance().getIconSpec("flags/flag1");
          setImage(new BinaryResource(iconSpec.getName(), iconSpec.getContent()));

Eclipse Scout Homepage | Documentation | GitHub

[Updated on: Thu, 23 May 2019 09:39]

Report message to a moderator

Previous Topic:Resizing font icon in AbstractImageField
Next Topic:create permission
Goto Forum:

Current Time: Wed Dec 11 14:14:59 GMT 2019

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

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

Back to the top