Putting files into APP/PUBLISHED

Hi,

I was wondering if there’s an easy way to just define a file that’d would appear at, for example, in the URL myapp/APP/PUBLISHED/myfile

What I’m looking for is something similar to the annotation @JavaScript("myfile") without the javascript part.

The @JavaScript annotation puts the file to the URL. But it also causes the file to be loaded as javascript and I don’t want that. Just to simply make the file available at APP/PUBLISHED/myfile (or any other URL on the server).

How should I do something like this, or am I trying to do something stupid?


The use case I have is that I try to make a component that uses a javascript library (
Ace
). Otherwise the @Javascript annotations work great but the javascript library contains some js files that it loads dynamically whenever it needs them. The files have to be available somewhere on the server but not loaded like the @JavaScript annotation does.

Another use-case:
refered library contains links on its own default images like (http://localhost:8080/MonitorNotification/APP/PUBLISHED/public/notification/gritter/images/gritter.png)

Everything could work, if /APP servlet could serve .png files too…

Hi there,

I had the same problem. The way I solved it was to explicitly add resources in my maven pom.xml:

<build>
		<resources>
       		<resource>
		        <directory>src/main</directory>
       		</resource>
       		<resource>
		        <directory>src/main/java</directory>
       		</resource> 
       		<resource>
		        <directory>src/main/webapp</directory>
       		</resource>
       		<resource>
		        <directory>src/main/resources</directory>
       		</resource>
	    </resources>
...
</build>

This way, all the resources were copied and the imported javascript file was successfully located. I hope it works for you, too.

Do you know how to add such directory resources in code rather than pom.xml (I don’t use Maven, and it must be doing something through the Vaadin API in the end)? Thanks for any tips as this is a common need for those building JS components.

David, check your IDE’s compiler settings, for example in IntelliJ IDEA you should add
*.js
to the list of resource’s extensions (screenshot attached).
13139.png