It seems when I manually build my gwt app, and run it on jetty, i get a blank page. I could add tags within the html document and see its content (ex add a table, i would see a table). But it seems like the modules javascript is never loaded.
This would be the command I manually run: mvn gwt:compile jetty:run
When I run my app on GWT Development Mode using their IDE, everything shows up as expected, I see my module being loaded and its contents.
Note I am using the RootLayoutPanel, would I be required to use UI binding?
If Development Mode works but compiled & deployed files do not, well, it looks like a deployment issue. To check, get Firebug for Firefox (or the equivalent tool for your preferred web browser), and check the HTTP requests made when the page is loading - you will probably find that some requests are 404, and that GWT compiles JS hasn't been copied over to the proper spot.
Related
I'm just starting to learn Spring reading "Spring In Action" and I cannot get my image to load on anything other than port 8080 (where tomcat launches). This would be fine normally, but I have to keep restarting the program to load any changes to my webpage.
Intellij tries to run my web program on port 63342, but no images load, only text. I believe this is an issue with Thymeleaf. I tried pointing tomcat to port 63342 but it won't load (port is in use?)
I would like it to where I can get the reload on save feature to work, and especially being able to use the shortcuts in intellij to launch the web page.
Any suggestions?
Basically the problem is, as I understand, that you're trying to open your .html template directly from IDEA. Which means you're not using the thymeleaf engine to render it - you're just opening the template itself and not the resulting page. If you open the source code of this page using your browser's dev tools, you will see that all your expressions stay unprocessed which leads to it trying to fetch the resources on the wrong port (e.g. 63342 instead of 8080 where your application is really running and is ready to serve the resources).
Thus, you cannot edit your templates like this. But Thymeleaf does have an option to do that. If you're running your Spring Boot application from the IDE directly (e.g. a profile in Intellij IDEA Ultimate) you can add the following to your application.properties:
spring.thymeleaf.cache=false
This will tell your Spring template resolver that you do not want to cache your .html templates and it will load the files from disk every time, so if you modify your template and then hit IDE's build button it should re-package your template and when you refresh your page in browser it will load (and process!) the edited one.
Caution! Only use this for development builds, set value to true for production environments to prevent unnecessary re-reading.
See Spring Boot Docs on Hot Swapping for more.
if you want intelj to display your image you have to add a regular src and add a th:src to show the image when the program is run. Try adding both
<img th:src="#{/assets/img/image.svg}" src="../static/assets/img/image.svg"/>
I am running an app in Java Spark Framework. I run it in Eclipse with Debug-As->Java App. This successfully deploys the changes to the Java files. That is, I save a Java file, and Eclipse compiles it, and the running app reflects the changes to the Java file.
Spark uses an embedded Jetty server under the hood, so this is just like running a embedded Jetty app in Eclipse.
Anyone aware of a good way to cause the HTML and JS changes to also be auto-deployed?
In order to auto update the static files of your project, you can reference them as external static files. You're probably doing this:
staticFileLocation("relative-path-to-html-and-js");
Instead of the above, do the following for debug purposes:
externalStaticFileLocation("absolute-path-to-html-and-js");
By doing so, when you press F5 in your browser, you're going to get all your changes to html and js code shown. It's even unnecessary to restart de debugger. Restart the debugger just in case you modified your Java code.
In Netbeans 8: a new HTML5 project using AngularJS online template lets me runs the html files with the debugger attached to browser and I can set breakpoints inside Netbeans JavaScript files to debug. Which makes things ALOT easier.
But when I create a Java maven based web project with AngularJS dependencies I have to use the browser's code viewer to debug the Javascript code. Which is more time consuming.
How can I debug JavaScript files inside Netbeans instead of debugging in the browser for a Java maven based web project ?
You don't / can't directly. While it is possible to run a Java based Javascript interpreter you won't have access to any browser windows or DOM elements. Instead, you almost certainly want to use EmbeddedBrowser to launch and control Firefox, Safari and/or IE depending on which you wish to test with in Netbeans. Note that it's running an external process to do this, and I don't think you'll be able to access the browser developer tools from within the embedded environment (which is what I normally use when debugging Javascript).
I have Eclipse, the Juno release. Just recently I am getting a few JSP errors which aren't valid or I don't care to see. Examples of the errors are below.
The function fn:replace is undefined
Attribute (cellpadding) is obsolete. Its use is discouraged in HTML5 documents.
The function error is not valid, as it working perfectly fine when I run the web application. I simple don't care the HTML5 related obsolete messages. I'd like Eclipse to not display these "errors".
I've tried enabling project specific validations, and turning off the HTML, JSP, & Tag validators, but it made no difference.
Maybe you mean that your project is using using older type of (x)html. If you don't like Eclipse falling by default to HTML5, go to project properties, then Web Content Settings, then in Document Type select the one you use.
I've heavily edited this question because responses indicated I wasn't being clear
problem: UI changes to a Java web project can be tedious and time consuming because every web-app file is contained within the WAR
my proposed solution: Manage the JSP's, CSS, JS and Tags separately from the application code base which for the purpose of this question I'm defining as:
All Java Source Code
Custom Tag Libraries With Compiled Java (extending TagSupport)
Spring Configuration Files
Web.xml
Jar's
+ Source
+ WEB
- WEB-INF
- JSP
- Tags
- lib
- HTML
- CSS
- JS
What would be nice is if after the major initial release and maintenance cycle, changes to view files could be treated as a different kind of release than a change to the Source. Source changes would be committed normally, and the application version would change. However, a change to a CSS/JS/HTML and even a JSP could be made in a test environment that is internally viewable to test new looks, add links, and so on. Technically, a JSP could even be added and as long as the controllers (like mine do) can be configured to show new JSP's without any Source modification, pages could be added without any deployments.
USE CASE - Owner of the site is running a promotion, he has a fancy graphic to link to an informational pure HTML page and wants it added to the home page.
Now imagine this work-flow:
UI dev opens dreamweaver and can FTP into Staging (staging may be a bad name, but basically a live test server). He can see:
- JSP
- Tags
- HTML
- CSS
- JS
Now he brings in the HTML file with information on it, adds it to the HTML directory. He then goes into JSP/home.jsp and finds the component that renders an advertisement on the right column, directly below it he adds his nifty image, saves his changes, opens his browser and goes to the live Test URL. He sees his image, but the component no longer renders the advertisement. Oops, he calls a developer and the developer says no problem
$ staging - > ./rollbackView -mostRecentBackup
The UI guy checks the site, everything is back like he never touched it.. now he more carefully adds his graphic and HTML, realizing that he cut off a JSP custom tag before. Now, QA, whatever that is for the project looks at the site, runs selenium, whatever. It all looks great. The developer gets the ok to release the changes
$ production - > ./updateProductionView
the script checks the application versions, ensuring they are identical, then copies over the view files. It's now 8:45 and the website owner (for us internal) is very happy that his new idea was implemented in the first 15 minutes of the day
Now the developer wants to create a patch that allows something cool, he updates his project, and the new view files are present. Maybe this isn't possible, but he could run a script, or use a second source repository like Mercurial to manage the views (ideas?) and he has the project and view files he needs. He makes his changes to the source, and views, whatever he needs. Now that is complete he can check in his changes and bring the WAR to a directory on Staging
$ staging - > ./deployStaging -overwriteView
The full war is deployed, and the JSP's are now what he had in his project. If the UI guys had made changes to staging, they will be overwritten (backed up maybe?). He could leave off the '-overwriteView' flag and the view files would remain untouched. At this point a full QA regression, integration and unit tests have been run, it's time to patch the main application
$ staging - > ./deployProduction
A full deploy is there, the application version is now V1.1 and everyone is happy
My Questions:
First, has anyone done something like this? If so, are there any good recommendations you can make? Development is done on Windows, but the production and staging servers are running Unix. All servers run the same version of Tomcat.
I'm looking for ideas for scripts that would allow Staging web files to be backed up, and hopefully even committed to the main project, also scripts that could take
What has been overlooked? Can I keep the project structured the same? Will this cause problems with CVS?
Is there anything that isn't possible or technically feasible here?
Can you point your UI resources to other folders? This way you set up the symlinks once on the test server(s) and allow the UI developers to manipulate the 'live' files. If these folders are source controlled then the UI devs could rollback their own changes if necessary.
http://www.isocra.com/2008/01/following-symbolic-links-in-tomcat/
If switching away from JSP is an option you could use a template system (Velocity or Freemarker for example) and store those resources outside the deployed war, on the file system or in a relational db for example.