How to access programmatically the VAADIN folder?

Hi,
I am trying to integrate a third party component with CUBA and I have the following problem. The third-party jar requires several resource files to be stored in a folder - so I have created a subfolder under VAADIN (see image below)

image

When I initiate the component from a screen controller in the web module, this component requires the path of the folder that has been created inside VAADIN folder. So, I would like to ask you if there is any method that returns the absolute path of the VAADIN folder.

Thank you

Hiello @papageor,

As an example of programmatically usage of files in VAADIN folder is a RelativePathResource (see Image sample).

If you just need to add CSS or JS resources to the page from VAADIN folder, since 7.2 it will be possible to use ScreenDependencyUtils:

ScreenDependencyUtils.addScreenDependency(this,
                  "vaadin://subfolder/mycomponent.css", Dependency.Type.STYLESHEET);

Hi Roman,
Thank you for your reply but I need some additional help. Please find below a sample of what I want to achieve:

String resourcesPath=“C:\Users\…\tomcat\webapps\app\VAADIN”;

FinancialModel fm = new FinancialModel();
fm.setResourcesPath = resourcesPath;
fm.runPredictions();

In the object of type FinancialModel, I need to setup a path for related resources - these resources are a group of XML related files that are required by the Financial Modeler component. So, I have stored all xml files in a subfolder of VAADIN and I wish to tell the system where to look for these files during the initialization of the component.

Thank you

You can use VaadinService to get base directory. It will return path to your “app” folder in the “webapps”.

VaadinService vaadinService = VaadinService.getCurrent();
String absolutePath = vaadinService.getBaseDirectory().getAbsolutePath();

Thank you very much! This is what I was looking for.

Regards,
George

1 Like