I have created a new link in the Welcome.java as the following
private Link<Void> drawLink;
drawLink = new BookmarkablePageLink<Void>("drawSome", drawSomething.class);
add(drawLink);
The following goes in the Webpage.html
<li>
Draw
</li>
There are two issues I want to fix.
I get the url as
localhost/project-name/wicket/bookmarkable/package-name.drawSomething?0
but I wanted the link to be as
localhost/project-name/drawSomething?0
As the drawSomething is a new page added to the project, like welcome page I am having a drawSomethign.properties file for page.icon and page.title.
page.title=D3 vis
page.icon=images/home_page.png
The drawSomething page loads the page title but throws an error for the image as could not resolve images folder.
But I have images folder in src/main/webapp/images/home_page.png
Can anyone please help me resolve both the issues.
Do this during you application initailization:
#Override
protected void initialize() {
mountPage("drawSomething", drawSomething.class);
}
Path to the images folder is relative to webroot path, try ../images/home_page.png
Related
I am making a Qute Template and there is a logo image in the header that I need to have loaded.
The path that is being used within the html is this:
<img style="width: 10cm;" src="logo.png" alt="Logo Flower">
The image path from the main folder is resources/META-INF/resources/logo.png.Click here to see the folders.
When the template is rendered, the image is not loaded and shows an error on the GET request:
GET http://localhost:8080/api/user/logo.png 404 (Not Found)
Does anyone have an answer on how to put the path of static files correctly in Qute templates?
It seems your HTTP path is wrong. It should look like this:
GET http://localhost:8080/logo.png
Try to inspect (CTRL + I) your page go to sources and try to figure out where is the problem...
Here is example on my project: META-INF/resources/logo.png
resources path
, and here is my img tag <img id="logo" src="logo.png" alt="Logo">
I am trying to give background. Image load properly when the url is (in login page)
/jobsspectrum/login
by using in profile page
<body background="resources/images/black.jpg">
But when the url changes the image does not load. eg.
/jobsspectrum/user/profile
because there is /user in the url before the page where i am using image in profile page.
the Error is
message /jobsspectrum/user/resources/images/black.jpg
description The requested resource is not available.
My image is under resources/images
It does not pick the resource when the url is not /jobsspectrum/
My resource handling class is :
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("resources/");
super.addResourceHandlers(registry);
}
I simple words the image is picked only in the front pages and when the user logins my url changes from /jobsspectrum/ to /jobsspectrum/user/** and the resource image part is not loaded properly.
Use absolute paths instead of relative ones.
With the JSTL:
<body background="<c:url value='/resources/images/black.jpg' />">
Or, without the JSTL:
<body background="${pageContext.request.contextPath}/resources/images/black.jpg">
This question already has answers here:
Android - local image in webview
(11 answers)
Closed 6 years ago.
I found out that in earlier APIs of android (KitKat and abover), local images (for example pictures in assest folder) can't be load in WebView! I have a html file that contains tag to show images.
<img src="blacksmoke1.jpg">
And I put blacksmoke1.jpg in assest folder. but nothing shown in WebView.
This is the problem: https://code.google.com/p/android/issues/detail?id=63033
How can I fix it? Is there an alternative way to show pictures in webview? Or Is there a custom WebView that i can implement in my app?
Edit:
This my assest folder:
Try creating a web pages in your assets directory and creating HTML pages that display the images. Then call a web page using this:
webview.loadUrl("file:///android_asset/blacksmoke.html");
Or, according to one of the posts in your link, move the html file to a server and use this code:
loadDataWithBaseUrl("content://<your contentProvider>/blacksmoke.html", ...);
Code in blacksmoke.html could be:
<!DOCTYPE html>
<!-- Perhaps some JQuery mobile for more functionality and control over which images get displayed and why etc -->
<body>
<div><img src="image/blacksmoke1.jpg"></div>
</body>
</html>
Here is a good explanation for creating native pages or displaying native images.
This is what I do to load local resources in webview from assets folder:
StringBuilder sb = new StringBuilder();
if (notification.get_id().equals("53be76c3d6eac5f54a546176")){
sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <title>For.... <img src=\"data1/images/forum1.jpg\" alt=\"\" title=\"\" id=\"wows1_0\"/> </body> </html>");
That is the html i want to load, if you notice there is an img tag, loading an image from data1 folder which is placed in assets folder. In order to be able to load resources from there I do the following:
WebView webView = (WebView) findViewById(R.id.webview);
webView.loadDataWithBaseURL("file:///android_asset/", sb.toString(), "text/html", "utf-8", null);
Hope it helps
after adding a javascript file to my Wicket panel like so
renderJsHeaderItem(response, "js/jquery/dist/jquery.min.js");
I get an error in the javascript console along the lines of
GET http://localhost:9080/js/jquery/dist/jquery.min.map 404 (Not Found)
How would I add the map file to my Panel code? (same question for css.map)
Thanks!
Wicket 6 comes with jquery so you dont have to add it again. You should add javascript and css files in your base page, that way all of the pages that extend the base page will have these files available and you only have to add them in one file.
To add javascript or css in renderHead use:
JavaScriptHeaderItem.forUrl("js/jquery/dist/jquery.min.js");
CssHeaderItem.forUrl("css/style.css");
Example:
#Override
public void renderHead(IHeaderResponse response) {
response.render(JavaScriptHeaderItem.forUrl("js/jquery/dist/jquery.min.js"));
response.render(CssHeaderItem.forUrl("css/style.css"));
}
I want to render content that i have created locally using html component and put image in this html also by putting image in res folder in jar, i tried
<img src='images/down.png'></img>
<img src='res/images/down.png'></img>
<img src='./images/down.png'></img>
but nothing worked, any suggestion?
[EDIT]
here is my code, i have no idea how to implement DocumentRequestHandler that is why i used DefaultDocumentRequestHandler
DocumentRequestHandler handler = new DefaultDocumentRequestHandler();
HTMLComponent component = new HTMLComponent(handler);
component.getStyle().setBorder(Border.createLineBorder(1));
component.getSelectedStyle().setBorder(Border.createLineBorder(1));
component.setBodyText("<div><b>nirmal:</b>" +
"<img src='res://images/down.png' /></div>");
tried res://images/down.png but nor worked
my image is in res/images
You need to explain how you loaded the HTML, images are loaded relatively to the base URL so you need to define the base URL when creating the HTML (its implicitly detected when loading via URL).
If you created the HTML via setHTML(String) then you need to give absolute paths depending on your DocumentRequestHandler implementation e.g. res://myImage.png or file://myImage.png .