I have a little question on how Vaadin and GWT works. When I develop my views using Vaadin or GWT I only write Java code. But when does my Java is generated into HTML and JS files ? During the compilation of my project or on runtime ?
I tryed to find this information on the Vaadin guide but I didn't found anything yet :(
edit:
Not really duplicate of Cannot run mvn vaadin:compile on Vaadin Maven project, I don't have a problem with the code or execution of my project but for myself, I just wanna know when does Vaadin or GWT generates its HTML and JS files ? During the Maven build itslef or on runtime, on demand only?
In vaadin you have to distinct two things:
Backend is written in Java and is run on a servlet engine like Tomcat, Glasfish,...
Frontend is written in Java, GWT or Javascript
For the backend the java compiler just creates the .class files from the .java source code
For the frontend, the java code is GWT based, and thus compiled into highly optimized javascript code, this happens in the "Compile/Build Widgetset" phase ob your build process
Frontend code can also be written in javascript, this is then passed as is to the browser, but with the addition of some logic to connect the JS components to it's serverside part.
The generated frontend javascript code is then also responsible to build the html content.
The Vaadin Architecture
Related
I am a beginner and self learning web development for my personal interest, and I have a general question.
I developed a Dynamic Web application in eclipse which uses index.php (or .html ; I can choose) to make a call to javascript file, the JS file calls a java servlet for some optimization and internal calculations through AJAX call, and returns back data to JS and later to the HTML form on index.php. All the paths and mappings are done on web.xml file, and everything works perfectly! The project involves some external google libraries as well, which I have included in eclipse through Build Path.
Then I installed Wordpress locally through Xampp and copied all these files (including all the java classes and external JARs) keeping the folder structure same. Here, index.php does make the call to javascript file, but for AJAX call to java it shows me network error 404. So I have 2 questions:
Does the Wordpress doesn't accept mapping through web.xml? Should I only use absolute paths? I am avoiding absolute paths since I want flexibility in moving files around and I don't know how it will work online when I upload my project somewhere.
Or is the Wordpress/ Xampp not building/ compiling Java classes and external JARs somehow like it is done in Eclipse? I have no idea how this works! I did copy all the updated class files and stuff to the wordpress folders.
Please let me know how to proceed from here, or any suggestions in things I need to learn! I am keen to use Wordpress since it will save me lot of time in writing all the page codes for my website but the java file is also integral to it since it does lot of backend work. I saw lot of comments online that wordpress and java don't go together since it being a PHP based (I actually learned PHP due to this), but it works in eclipse using these 2 languages, so I am hopeful!! So any guidance will be really appreciated!
Thank you! :D
Anang
I am new to front end developing. I have so far a back-end program written in java with Eclipse that does all I want, saves the output in an object and prints it in the console (for my convenience).
My goal is to display this output information dynamically (meaning that the backend part of the program might update and send new output) in a webpage on a local server.
Hence I have "transformed" or "added" a Dynamical webpage to my Eclipse project using "Project Facets" in Eclipse Project Properties, and created an index.jsp file hosted on a tomcat server (See picture of the File organisation).
Ultimately, I want to have my index.jsp file open in my browser and when my backend program (which I assume I have to compile in an executable jar) detects changes , display those changes in the webpage. Also, I have a button on my webpage for which I would like to send information back to my backend program when it is clicked.
Should I use POST request in my backend with the URL of the index.jsp (although I don t want to display the information in a form, just regular text and images)?
or create a Javabean class in the webcontent/WEB-INF/ (if I can access and modify it dynamically from my backend) and then use that to get and set data from the jsp page?
or am I obliged to use something like Spring ?
I ve heard I should seperate backend and front end, but I don t really understand how they communicate dynamically !
Thank you for your help !
Seeing your project structure I believe you want to build a simple Java Web, you don't need to separate your front-end and back-end unless you want to build something complex.
I'm not quite sure about your experience with Java Web, but if this is your first time I suggest to learn more about Servlet because this is the fundamental in building Java Web project. After knowing how Java handle Http Request is up to you to build pure Java Web project, or using something like Spring MVC even if you want to build a separate front-end that communicate using REST API towards the back-end.
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).
As a project, I wanted to build a personal website using Java for the server-side code. I am very new to Java and wanted to know if it was possible to write Java using a simple text editor, upload the file into a file directory in Apache Tomcat where the corresponding JS and HTML file sits (for practice purposes only), and then run the web project through the HTML file.
I do this with php through LAMP all of the time, and was hoping Java might work that way as well.
Yes its very much possible. Even though you may find it bit difficult without the help of IDE, this should not make any difference. Convert the files to proper class files and upload it, that should do
Though i agree with above answer.But you can also go for hot deployment plugins for example mvn:jetty plugin for hot deployment of your website, but for that it needs to be maven project.Also grails and many other framework has this features inbuilt.
I just needed to create a little interface for a project. So I decided to take given code and to run it on Google AppEngine. My problem is, that I'm experienced in JavaScript and got some basic knowledge of Java, but I got no clue how a Java webapp has to be structured. I started Eclipse and installed the AppEngine-addon, downloaded Rhino and env.js (which is necessary for the bunch of code I need to run) but then found me in the situation of sitting on this files not knowing where to put them.
It would be great if someone could tell me in which directory to put which files for Rhino (I assume it's "/war/WEB-INF/lib/"), how to add the env.js-file and how to access all these files inside the .java-file which is the index of the app.
I don't know about app engine in particular, but I have had good success using Rhino jsc to compile script files which extend the Servlet API. The end result is a nice WAR file which you can deploy in any servlet container, and perhaps App Engine as well. See here for my relevant blog post about this technique, and here for a sample Eclipse project.
Have you taken a look at this tutorial on running Rhino on GAE?
It's a link from the official "Will it play in App Engine?" thread.
http://www.appenginejs.org/ may be of interest as well.