I have the following line of code to set the URL of an image I want to display
img.setUrl("images/img1.jpg");
Where should I place my images folder in order for it to get picked up correctly. Currently I have it in my WEB-INF folder but this does not appear to work. I get the error on my console "WARNING: No file found for: /images/img1.jpg"
I created my project using Eclipse and I have not changed any folder structure.
You should make a folder named images under your war/project_folder and place the images there.
And while setting the Url you shoud do
image.setUrl(GWT.getModuleBaseURL()+"images/im1.jpg");
You can use either GWT.getModuleBaseURL() or GWT.getHostPageBaseURL().
Create a public folder (named "public") alongside with folders "client" and "server". The content of the public folder will be copied into the war.
>src
>com
>test
>client
--->public
>images
>server
>shared
Voilà!
It is always better to use absolut URL rather than relative URL by using GWT.getModuleBaseURL(). If you want to use relative path, then your image should be in the war as described by your relative path.
In your case it is
war->images->img1.jpg
You need to put the images in the web app directory.
You can check your web app directory here
Proeect --> Properties --> Google --> web Application
Here you will find the WAR directory
So in this directory , you need to put your images.
You can put the image directly or else you can make folders as you want
sample -
image path --> WebContent/img/pics/recent/data/1/1.jpg
String imagePath = "/img/pics/recent/data/1/1.jpg" ;
Image img = new Image(imagePath);
NOTE :- How ever GWT Image does not understand absolute file path , you need to use relative file path
Related
I have to upload a file from a different folder than /fixtures.
If I use attachFile it always adds the path cypress/fixtures in front of it.
cy.get('input[type="file"]').attachFile(this.uploadFileName );
cy.get('#file-submit').click();
Where this.uploadFileName has an absolute path to the file.
The file is generated before, so it is not really a fixture anyway.
Currently, attachFile can only import file from the fixtures folder. Hence, the generated file has to be imported into the fixture file (via task and fs.copy()).
I have a gradle build which generates war file. I want to copy war file to my application servers' dropins directory which is somewhere outside of project directory. I have following copy task to do this.
task copyWarToDropins(type: Copy,dependsOn:[war]) {
from './build/libs/bds-service-token-1.0-SNAPSHOT.war'
into file('/apps/dropins') // want to copy to 'C:/apps/dropins' directory
rename { fileName -> 'bds-service-token.war' }
}
build.dependsOn copyWarToDropin
It evaluates /apps/dropins relative project directory and does copy there. I have tried many ways I can think of but could not make it copy to C:/apps/dropins directory.
Can someone please help?
First, please note that using into file(...) is redundant, as each call to into(...) will be evaluated via Project.file(...) anyhow.
As you can read in the documentation , file(...) handles strings in the following way:
A CharSequence, including String or GString. Interpreted relative to the project directory. A string that starts with file: is treated as a file URL.
So, one way to solve your problem could be using an absolute file URL.
However, if you continue to read the documentation, you will see that Java File objects are supported. So you could simply create such an object:
into new File('C:/your/absolute/path')
I have a Xamarin.Forms GetFiles.IOS project that has a "Resources" directory that's part of the project. I have placed 25 files into the Resources Directory. I now want to be able to go to the resource directory and get all the file names. I created some code to read the files in the directory but I'm getting a DirectoryNotFoundException. Here's the code I'm using.
String dir = Directory.GetCurrentDirectory();
var filePath = Path.Combine(dir,"Resources");
String[] files = Directory.GetFiles(filePath);
I just can't seem to get the path correct!
Thank you for helping me.
There are two things necessary to have the files be copied into the app folder:
They need to be set with Build Action Content with Copy to Output Directory Copy Always in the Properties window.
They must be in a different custom folder than Resources.
Number 2. is because Resources is a special reserved directory name and even if you put some content files in it, it is never copied in the app bundle's folder. You can check for yourself, if you put the files in a folder Test, your code will work as intended.
I am using asciidoc with asciidoctor to create documentation for a current project.
I notice there is a markup to include files in the documentation like so:
link:index.html
or
link:protocol.json[Open the JSON file]
Is it possible to include a docx file as a link so that it would open externally or be able to downloaded?
Also can I put this file in a folder inside my asciidoc directory (for the sake of organization) and still be able to properly reference it?
You write something like this:
Open this link:somefile.docx[Word file] should work.
Or this link:file:///C:/Users/xxx/docs/otherfile.docx[second file].
It works with relative path or absolute path.
You need to ensure that the path to your file will be correct for the reader of your document.
Example: if you put the HTML files produced by Asciidoctor on a webserver (public or intranet), having a path referencing your local C: is not a good idea.
It is hard to tell you what to do without knowledge of your publication/distribution toolchain.
I want to set my relative file path in a properties file so my SaxReader can pick it up when it runs on Tomcat server. I know this should be easy but I've forgotten forgive me :)
I know Spring Boot has application.properties file but I don't see a way to hook in here.
Is there a way to set the relative path in a properties file that will get picked up by Spring Boot and the SaxReader will see it?
As it is I'm hard coding just the filename and putting the file in the resources folder that serves up the templates and static content such as css and js files. The filePath system.out gives: org.dom4j.DocumentException C:sts-bundle\sts-3.7.2.RELEASE\myFileName the toolsuite root location??? weird!!
Please tell me how to specify the relative path in a properties file.
Thanks!!
You can set the file path like any other string property in Spring Boot properties file and access it from inside the path.
E.g. I have the following set in my application.properties file:
download.directory=temp
and it is used as follows in java class:
#Value("${download.directory}")
private String downloadDirectory;
It is used to download the files, now, if I start the application with jar file present in let's say G:/applications folder then the files will be downloaded into G:/applications/temp.