I've written a java server side application with many classes and EJB's that do things like output RSS information and update a database. I also have a web service connection thorugh SOAP and some basic servlets and xhtml pages that do very simple display of some of the infomration.
What I need now is advice on what a good Java centric approach to building a rich client side experience, and RIA that connected to the server side functionality I've created.
I'm using Glassfish 3.1, and JEE6. I'm considering Java Server Faces but it's more of a framework for developing simple webpages. What I want is a javascript heavy application that runs in the browser, is very graphical with animations and can connect to the services I've created underneath probably through websockets.
I want all of the AJAX, and Javascript support you would expect from a modern RIA experience.
What Java technologies will get me there. Or am I leaving the Java sphear and entering something else. I'm just trying to stay with java as long as possible for this application as an experiment of Java's abilities. So what Java tools are out there for RIA and integrated JavaScript?
Thank you,
For Java definitely the Google Web Toolkit.
You could also look at Vaadin. Unfortunately there isn't really
a good SOAP client for JavaScript but if you had a JSON REST webservice
and are willing to develop in JavaScript I also recommended
to look at frameworks like ExtJS, JavaScriptMVC or Backbone.js.
Related
I want to develop a web service.Out of Java web service and .Net Web API which should I select.
.My requirement is that it should be stable and should be effective in performance.Which should bare load of thousands of requests and won't fail.Out of this two which should I choose and why?
My suggestion would be implement Rest WS in Java, Since it's platform independent, rich API's, you can go with Spring for rapid development.
My suggestion is Java. I'm used to Java to build REST server that serve thousands request and it's still working well.
The Jersey is good framework for you. Also Java is open source and independent platform.
In JavaOne 2013 I attended a seminar on Project Nashorn. I was astonished after knowing about it. Calling Java From JavaScript and vice versa.
But one question is still unclear to me, that how can we use Nashorn in favor of Web Application Framework like JSF, ADF Faces or Wicket etc. If someone give any pointer, it would be highly appreciable.
Scripting API for Java Platform, in general, and Nashorn, in particular, open wide range of opportunities for web app development on JVM. Frameworks like node.js and vert.x solvency of JavaScript as server-side framework. Yes, we still waiting news about node.jar - mystery Oracle's project of implementing node.js API on Java platform.
In todays modern web applications we should think about server-side more as service provider (RESTful services) rather than presentation framework that generates html on the server. But even for server-generated pages you not necessarily need stick to frameworks like JSF, Wicket, ADF. With Nashorn/Rhino you can use JavaScript templates to generate html markup on the backend. LinkedIn, for instance, already described benefits of having templates written in JavaScript in both browser and on the server. In case when your browser unable to precess client-side templates you can graceful degrade and switch to server-side rendering.
If you're looking to example for to leverage JavaScript in server-side web framework you can start with Dust4j. Do not be confused by words Rhino in description. Dust4j doesn't use internal Rhino's APIs. It uses jsr223 APIs so if you run it on JDK8 or JDK7 with Nashorn backport it should work. Dust4j project shows how you can integrate scripting into you JSP/Servlet/Filter-based application.
Nashorn is a JavaScript compiler and runtime for the Java Virtual Machine. It is not a Web Application Framework in itself, but might enable one to be built on top of it.
Therefore, it isn't a replacement for JSF or ADF.
Apache Wicket provides a functionality to post javascript code against the server, now and also allow to access session / request scoped objects. It does not replace the Web Framework itself, but allows you to create a programming interface to run code on the server and modify java objects, calculate values and return the calculcation.
The documentation of Wicket's Nashorn Integration can be found here: https://github.com/wicketstuff/core/wiki/NashornIntegration
And if you fork the git repository you can run the nashorn integration examples:
https://github.com/wicketstuff/core/tree/master/nashorn-parent/nashorn-examples
One thing left to be mentioned: Because it is an arbitrary code execution this might lead to security issues, so ensure that only logged in users can access this interface.
I have a Java desktop app (with a Swing GUI) that runs in a LAN environment. Normally, I run it with a bunch of machines, some play the role of servers while others act as clients.
Now, I would like to run the same app on the Internet, where both the server and clients will be hosted on a website, so that visitors of the website will be able to run as the clients and interact with each other.
I wonder what are options are available for such migration? Do I need to re-write everything from scratch using some Java-based web framework? If so, how should I deal with the GUI part? Or do I just host the app as an applet? (somehow I am reluctant to go down the applet route, as it may require additional setup on individual visitor's machine I have no control of and there may exist compatibility issues). Thanks!
One option would be to use Vaadin. The programming mindset is quite close to JavaSE Swing. It is a GWT derivative on the client-side, but the logic is really on the server JVM and the framework takes care of the communication (xhr or web sockets).
Google Web Toolkit (GWT) could be usefull for that since it will let you re-use generic Java code and compile it to JavaScript for running in the browser. In my app I am reusing classes in the client that I use in the server. The UI has to be recreated using web widgets though however wysiwyg tools exist for that.
You could also migrate your raw sockets to Websockets if you require bi-directional communication.
If your code follows the mvc pattern it should be possible to reuse the model stuff. My favorite java web frameworks are those from spring source. Spring mvc (clean mvc design) or spring roo (more the rails style with code generation etc.). Both integrate well with the dojo framework (ajax / gui stuff).
Do you know a technology which can provide me a portlet-like interface?
But I do not want to use JSR 168/268 portlet specifications and a portlet container.
The reason is: My web app is a product which can be installed on the client's server (it can be weblogic/websphere/tomcat).
Packing the portlets container along with my application to be installed on clients web server is just too much.
Besides, there are a lot of features this technology offers which I don't need. Actually, all I need is the porlets look and feel (dragable and customizable windows,adding and removing windows and so on).
I know there is also the possibility to do it with client technology (like jquery) and that is cool, but I would like to know if there is any kind of java technology out there which will also give me that.
So, if you know something like a struts or a spring-mvc component library which does this job or maybe a third party product, I would like to know.
If you think my whole approach is wrong I would also like to know that.
Take a look at gwtportlets. From their site;
GWT Portlets is a free open source web
framework for building GWT (Google Web
Toolkit) applications. It defines a
very simple & productive, yet powerful
programming model to build good
looking, modular GWT applications.
The programming model is somewhat
similar to writing JSR168 portlets for
a portal server (Liferay, JBoss Portal
etc.). The "portal" is your
application built using the GWT
Portlets framework as a library.
Application functionality is developed
as loosely coupled Portlets each with
an optional server side DataProvider.
Take a look at the demo here
Another suggestion would be JSF 2.0 which provide AJAX support for updating part of the HTML-page out of the box.
Have a look at this series to get an idea of the possibilities:
http://www.ibm.com/developerworks/java/library/j-jsf2fu1/index.html
I'd like to learn how to create a java web service that can be consumed by a web tier, which is constituted of java and flex.
What books can help me learn how to create a java web service and consume it via java & flex?
Should I look to build a web service from scratch or from frameworks like: XFire, Axis, CXF, Spring Web Services, etc.?
If using a framework is recommended, which of the above or any others makes the most sense to learn/use?
EDIT:
Both the java AND flex components of the web tier need to independently access the web service. For example, the flex component helps the user create & save a spreadsheet; the java component retrieves the spreadsheet data and displays it accordingly.
Flex should do the job: Web Services with Flex tutorial
You may not need a web service. Your Flex app can consume Java POJOs directly using Spring and BlazeDS.
What kind of a service are we looking at? If it requires database integration you probably need at least some kind of a framework - you really don't want to be putting your SQL queries hard coded into the app. Spring + Hibernate seems to be one of the most popular choices for a Java server implementation, but both of them are quite massive and require some effort. Appfuse could be something that provides a good starting point for building a service.
Why do you want to do your service with Java anyway? Is this because you know only Java or because there is a Java container already running on your server? I've seen great results with Ruby on Rails too and now there's some buzz about Scala too in the Java world. This could be your chance to try out something new and more flexible ;)
I'll take this opportunity to plug my own book, Eclipse Web Tools Platform: Developing Java Web Applications. Chapter 10 deals exclusively with creating Java Web services. Although the examples are all shown using WTP tooling the lessons discuss Java Web services created with Apache Axis.