There are lots of great Javascript libraries out there these days for creating rich web applications and I would like to use one of them for the frontend of a website I'm working on as they seem to provide a way better interface than what you usually see with JSF, Facelets, PrimeFaces, etc...I read so many complaints about the presentation layer for Java EE and on the other hand things seem to be getting better and better when it comes to Javascript and HTML5.
I am wondering how to go about doing this? One JSP and Facelets you can have items in the presentation layer directly mapped to objects on the server. How would you deal with this when instead you use a Javacript library for your frontend?
I will use Java EE on the server but what is the best way of integrating this with a Javascript RIA library on the frontend?
If your question is only about mapping objects from the back-end to the JavaScript front-end, then I suggest using a JAX-RS implementation (RESTEasy, Restlet, Apache CXF, ...) in combination with Jackson (JSON provider).
This combination allows you to publish a REST API with your domain objects converted to JSON, so you can easily access these objects through JavaScript by using AJAX requests.
But of course this leaves a lot of communication handling open to the developer, if you want to have a more complete package, frameworks like Google Web Toolkit are probably a better solution.
A Google Web Toolkit frontend would be easiest to combine with a Java EE backend as it supports this out of the box with it's own communication system. Otherwise RESTful services are easy to communicate with from javascript and are easy to create in Java EE especially with the aid of an IDE like netbeans.
You can create a front end using JavaScript Libraries like JQuery, ExtJS, Dojo etc with HTML/ HTML5.
To communicate with a Java EE server, you can use an Ajax request with the response in xml/json format.
Related
My group has a project that is upposed to connect a web page to a databse. the webpage is written in html, css, and javascript, and the database is written in mysql. we know there are issues with accessing databases from javascript, so we built a driver class from java that is supposed to control communication between the two.
the problem is that we do not know how to connect javascript with java during runtime. the way it is built, the javascript simply needs to call a java function and get the results. is there any simple way to do this? perhaps a certain library? we have little to no knowledge of other similar tools (i.e. jsp, xml) and would like to stick to the languages listed above.
You can create a Java HTTP JSON server and then make a call to it from Javascript by using AJAX calls.
See here: Java simple HTTP JSON server
In order to provide easy access to java code(including static/dynamic web content) over HTTP interface you've to use one of the (servlet) containers - jetty, tomcat, spring-boot, etc.
In my opinion, since you've minimal experience developing/deploying java web applications jetty might be good option as it have good documentation to get started. Spring Boot is popular choice for Enterprise web development using Java - it might be more than you want to chew for the moment.
The Servlet(web) and JDBC(database) APIs what you will end up using on Java side.
I am planning a project where I will develop bots for Agar.io by using the NEAT algorithm, which is implemented in Java (this is called ANJI). I will use the open-source Agar.io server called Ogar, which is implemented in Javascript. The Javascript implementation should communicate with the Java library to evolve the bots while the game is running, but I have no previous experience of how to make Java and Javascript communicate. I have considered using Rhino, but it does not seem like it is possible to use in a browser. So, are there any way to let a Javascript implementation like Ogar use a Java library?
using the Rhino / Nashorm is not relevant in this case and as for performance focus its should be much hard to run nodeJS based application via Java JS engine.
the Agar.io server is a NodeJS server that expose a WebSocket API and the client solution need to communicate this way.
Using spring websocket client for example
have you seen Agar.io-bot ? its seems like the way they implement the BOT is javascript browser extension and communicate via the browser.
In common, Javascript and Java library communicate using Rest and Json, Java provide Rest API and Javascript send Json request to this API.
This is list of java library: for developing Java Rest API and working with JSON. I recommend using RESTEasy.
I'm developing a jQuery-based pivot table.
The goal is not a web app but a desktop-based application (C++). In my idea, data is retrieved by the application from the database, then passed to a html page and then showed through the pivot-table plugin.
There is no web server and the web page containing the plugin cannot access to the database.
So, how to pass data in an efficient way? I've seen other questions here on SO around this matter, but I think we're in a different scenario. Of course I can write the data in a txt/xml/js file, but I've experienced that for huge amounts of data, writing down files is costing a lot.
If you don't want to add support for the http protocol to your application, and you don't want to write to additional files, then IMO your best bet is to create a wrapping http server for your application. Then the javascript page can access the running wrapper which can talk to your "real" application.
You could create such a server relatively easily in python using the twisted framework, ruby using rails and the bundled webrick server, or the v8 Javascript engine node.js. (I'm sure there's dozens of other options out there too)
Which of there would be best for you will depend a lot on which languages you have experience with and what your deployment requirements are (supported OSes, existing installed applications, installation size, license terms on your software etc.)
Do you have a specific framework for your desktop app ? If you use Qt for the GUI, you can also integrate javascript quite easily.
http://efforts.embedded.ufcg.edu.br/qt/?p=84
You might be able to use named pipes to pass data to a static page.
It might also be better to just make your c++ program into a simple web server which opens a port, and have it generate the web page when the user goes to http://localhost:8080.
I am developing a Java web services application that is (mostly) to be used by other SOA clients. Currently I am planning on using CXF to publish my various web services & methods using SOAP/XML.
I am now being asked to investigate a thin client web-application for this tool. I have been looking into Javascript libraries such as ExtJS and Dojo -- and they seem really straightforward. Given that this is a web application and not a web site, I really don't think I'll be creating very many static HTML pages -- maybe even just one. Mostly I plan on using an XMLHttpRequest object to hit the web services I already have and take the results and modify the DOM.
However, I have never created a browser-based UI before and in the context of a nearly 100% Javascript application I am trying to figure what role, if any, a server side MVC framwork such as Spring MVC will buy me. Is it needed for this? Whats it good for?
If you use the CXF JavaScript client generator and go for a single page JS application, I don't see what a Java MVC framework will give you (apart from extra complexity).
Spring MVC is a web-based module based on servlets and JSPs. If you're writing a JavaScript UI that calls on services directly, I'd say that you don't need Spring MVC.
Exposition:
I'm familiar with C/C++/Scheme & OpenGL. I have this client/server program written in Clojure that serves as a todo-list/wiki/forum. The server is written in Clojure. The client is written in Clojure and uses SWT.
Question:
I want to rapidly create a web client version of this. What is the best way to do this? (I Don't use anything complicated, like OpenGL rendering in SWT; just standard widget stuff) I just want something accessible via Safari/Firefox -- and no, I don't want to run it as a Java Applet.
Thanks!
Take a look at Ruby on Rails, allows you to create very basic CRUD applications quickly. Personally I am looking more a Grails a very similiar framework but for a Java platform
Ruby On Rails - http://rubyonrails.org/
Failing either of those PHP is a good alternative and very quick to get started with
Adobe Flex/Actionscript is a pretty good approach for applications that require rich user interaction.
Google Web Kit allows writing of Java code (since server is in Clojure) to create AJAX api.