Unable to find file sources while loading an image

I have made a default project with the eclipse plug-in, but i don’t know where is supposed to put the file resources such as images or xml.


        Embedded image = new Embedded("logo-aviones", new ClassResource("/images/aviones.jpg", getApplication()  ));
        image.setType(Embedded.TYPE_IMAGE);

So I don’t know where is the “images” folder. and i get an nullPointerException.

Thanks :slight_smile:

ClassResource(path , getApplication()) will start looking for files in the source folder from the same package where you have your application. ThemeResource would probably be more appropriate for images. ThemeResource looks for files within your custom theme, see
the chapter on themes
in the Book of Vaadin.

I make my own theme copying the reindeer theme on the /WebContent/VAADIN/themes/testtheme

It reeds the providen CSS, but when i made the same request that i have exposed before, I’ll get the same

java.lang.NullPointerException
	com.vaadin.terminal.ClassResource.<init>(ClassResource.java:75)
	com.example.test.DivisorComponentes.<init>(DivisorComponentes.java:29)
	com.example.test.TestApplication.init(TestApplication.java:14)
	com.vaadin.Application.start(Application.java:545)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1008)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:418)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

The DivisorComponentes class is the one that makes the call to the image loader.

        Embedded logo = new Embedded("logo-aviones", new ClassResource("../img/aviones.jpg", getApplication()  ));
        logo.setType(Embedded.TYPE_IMAGE); 

I’ve tried putting as path “/” , “…/” and whitout the slash …and i’ll get the same error.

Thanks in advance!
11132.jpg

You don’t need to copy the entire reindeer themes folder to be able to extend it. Just create the testtheme -folder under the themes-folder (as you’ve done) and in that folder create a file called “styles.css”. That file should contain the following row, nothing else:

@import url(../reindeer/styles.css);

To access the icon, you should use the ThemeResource and not ClassResource.


Embedded logo = new Embedded("logo-aviones", new ThemeResource("img/aviones.jpg"));
logo.setType(Embedded.TYPE_IMAGE);

11133.png

Oh, and make sure you’ve called setTheme(“testtheme”) somewhere within your application class, for example in init().

Thank you very much …you have relief my headhache :smiley: