GXT 2.2.5 give ugly page - java

My project: GWT 2.3.0, GXT 2.2.5 Server: Glassfish 4.1. IDE: NetBeans 8.0.1 with plugin gwt4nb.
I try create simply GXT project but when i run application it give me page with only label and button looks like html. If i want add slider or other component - browser doesnt display this (I think code wasn't compile to html, css etc).
step by step what i done
1.Create new project: web application and technology: gwt
2. Add library to classpath gxt.jar
3. Add resources from gxt.rar to war folder in my project
4. Add <inherits name='com.extjs.gxt.ui.GXT'> to Main.gwt.xml
5. Add <link rel="stylesheet" type="text/css" href="resources/css/gxt-all.css" />to html

I think the problem is your gwt apps can't load the gxt-all.css. This is one of many ways to include the gxt-all.css file :
Create a new folder in you webapp folder (same level with your host.html file) and named it resources
Then inside the resources folder create another folder name css
Copy the gxt-all.css file inside this css folder
Clean your workspace, and restart you gwt application, and you should be good now.
Hope this helps. Thanks

Related

Servlets: can't link css from jsp: cannot resolve directory resources: ${pageContext.request.contextPath} links to root instead of src/main/webapp

I have this project structure (WEB-INF is inside src/main/webapp/):
I try to access a login.css from login.jsp using
<link rel='stylesheet' href="${pageContext.request.contextPath}/resources/css/login.css">
However Idea underlines it as cannot resolve directory:
I use servlets for this project, but however in the other project that uses Spring MVC, the same css link works perfectly. I suspect the ${pageContext.request.contextPath} links to a different folder in this case: to the project root (../src) instead of the root/src/main/webapp folder.
Is there a way to change where ${pageContext.request.contextPath} links to? Or some other way to fix it?
"resources" looks like a directory for maven or concept/grouping in your IDE. They are probably combined at the root of your WAR> My guess would be that your you should remove "resources" from the link as they really reside at the root of your web app.
${pageContext.request.contextPath}/css/login.css
Take a look at the WAR that is actually produced and where they would be in that.

Thymeleaf and Spring Boot, how to construct assets folder to view html both in runtime and designtime

I have a Spring Boot 2 project and use Thymeleaf template engine.
The folder structure is:
main\
resources\
static\
assets\
css\
my.css
js\
templates\
index.html
(1) If I refer my.css as ../static/assets/css/my.css in index.html, I can view index.html directly in browser(file:///path/to/main/resources/templates/index.html) but if I run the project in JetBrains IDEA, and browse it as http://localhost:8080/, the browser console tells can not found my.css.
(2) If I refer my.css as assets/css/my.css in index.html, When I view index.html directly in browser(file:///path/to/main/resources/templates/index.html) the browser tells can not found my.css, but if I run the project in JetBrains IDEA, and browse it as http://localhost:8080/, the browser view becomes OK.
Because Thymeleaf site says it is friendly to both design time, runtime and cooperation with programmer and designer, then can anyone tell me how to construct my static resources and html templates folders relationship to achieve this target? Thanks a lot first!
In Spring boot static files are served from the location src/main/resources/static and are available at the root of the application URL.
For example, if you have src/main/resources/static/assets/css/my.css, then when you run the application it is available at the location http://localhost:8080/assets/css/my.css.
So you can include it in your index.html as follows:
<link rel="stylesheet" href="../static/assets/css/my.css"
th:href="#{/assets/css/my.css}" />
This way when you just open index.html in the browser, it will detect the CSS using href and when you launch it via the server i.e by running the app and the opening it in the browser, then Thymeleaf will process the th:href. So it would work in both cases.

Issue with including css to jsp in java application

I'm developing java application and I'm using bootstrap. When I use CDN url to obtain css it works ok. But I when I tried to add css localy it didn't found it.
My project structure:
Maybe something with path?
Thanks to all who commented on my qyestion. So as I've searched for a correct structure of maven project with css and views I've learnt that all css/jsp/js should be located in webapp folder. best practise is to create "resources" folder and then add css/js/jsp in there.
Something like this
webapp
|___WEB-INF
|___resources
|____css
|____js
|____jsp

Open JSP Page directly in brower using URL

I am using Apache-Tomcat-7 and I placed a jsp page( myjsp.jsp ) in
...\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\desktop\
I have started the tomcat and trying the following URL to open the jsp page
http://localhost:8089/desktop/myjsp.jsp
But it is giving 404. I donot want it to open through other means. Can any body tell me that what I am doing wrong?
P.S. localhost:8089 works fine for other applications and tomcate is configured to this port-8089.
EDIT
When I placed the myjsp.jsp in ROOT folder under
...\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\ROOT\
and try
http://localhost:8089/myjsp.jsp
Now it works. So what is the reason that in the desktop folder the jsp was NOT found
OR
how can I access myjsp.jsp if it is placed within desktop folder?
Well one way is the way you have already done (by deploying it at the root context of the tomcat server). Although it would seem to work fine, I won't recommend doing that. Changing root context of tomcat to some other application/pages is for other purpose.
The best way to do is to create a small project (you need a dynamic web project with a proper deployment descriptor --> eclipse will do all this job by just a button click), then deploy this project to your tomcat server.
So lets say if you create your project as MyProjectOne, then just place your JSP page (lets call it test.jsp) under WebContent or src/main/webapp folder and you will be able to view your page as http://localhost:8089/MyProjectOne/test.jsp

Advanced GWT Components theme CSS not being loaded

I'm trying to use the AdvancedTabPanel of the Advanced GWT Components library. I've put the JAR file under war/WEB-INF/lib and added to my classpath in Eclipse, and added to my HTML file:
<link id="advancedTheme" type="text/css" rel="stylesheet" href="./advanced/themes/default/theme.css"/>
Although it finds the Java classes and loads the okay, it doesn't find the CSS. How do I point it to the CSS properly? I can see that the file exists under the JAR, as org/gwt/advanced/public/advanced/themes/default/theme.css...
Edit: I've also added the <inherits name="org.gwt.advanced.Grid"/> tag in my .gwt.xml as indicated in their Quick Start...
I had initially thought the resources for a module would be dumped into the root of the web server based on the Eclipse plugin's demo project placing some css/html files there - but they're actually located under a path named after the module. Once I changed it to reference <projectname>/advanced/themes/default/theme.css (or to reference it with a stylesheet tag in the .gwt.xml file) it worked.

Categories