I am quite new to Vaadin but have developed Java web applications for many years. I am not sure if I am missing a feature here when I expect links to be built with the context-path when using VaadinService#resolveResource.
My image is placed here: src/main/resources/META-INF/resources/frontend/images/image.gif
My application is deployed to http://localhost:9090/myContext
Here is my code:
String imageSrc = vaadinSession.getService().resolveResource("frontend://images/image.gif", vaadinSession.getBrowser());
Image image= new Image(imageSrc, "My Image");
Does Vaadin miss support for non-ROOT context or am I missing something? Also, I wonder why I cannot find a way to get the contextPath from a VaadinService. Do I need to implement my own VaadinServlet and save it away at init?
It seems like ServiceContextUriResolver has a hardcoded “/” where it should actually use the
resolved context root relative path that has been stored to ui.getInternals().getContextRootRelativePath() and is resolved as ServletHelper.getContextRootRelativePath(request) + "/" on bootstrap.
as a workaround you could probably use the following method while we try to figure out the problem:
I see where this is going. I am not sure where this code should be placed, as the super.resolveVaadinUri() call suggests this should go into a subclass of VaadinService, I do not find the extension-point to define my own VaadinService class.
If I register a patch for com.vaadin.flow.server.ServiceContextUriResolver in my own module, other URLs are not working anymore because they are using ./…/ as their contextPath.