Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 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: 55
Registered: April 2019
Member
Hi,
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 {
				@Override
				protected String getConfiguredImageId() {
					return "flags/flag1";
				}
				
				@Override
				protected String getConfiguredLabel() {
					return "Country";
				}
				
				@Override
				protected byte getConfiguredLabelPosition() {
					return LABEL_POSITION_TOP;
				}

				@Override
				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 {
	@Override
	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 messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
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:
http://localhost:8082/icon/flags/flag1.jpg

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):

        @Override
        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

Re: displaying images not from the default directory [message #1818691 is a reply to message #1807119] Mon, 23 December 2019 12:14 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
Hi Krzysztof, This bug is fixed in version 9.0.0.034.


Eclipse Scout Homepage | Documentation | GitHub
Re: displaying images not from the default directory [message #1821648 is a reply to message #1818691] Tue, 18 February 2020 07:57 Go to previous message
Krzysztof Leja is currently offline Krzysztof LejaFriend
Messages: 55
Registered: April 2019
Member
I confirm that it works with the above patch. Thank you!
Previous Topic:How to Load data in batch into TableField
Next Topic:Having a "frozen" column in a table
Goto Forum:
  


Current Time: Sat Apr 20 02:30:22 GMT 2024

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

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

Back to the top