I have a Java EE project using Spring MVC and maybe some JSP files (or plain html not sure yet)
I will use angular.js for the frontend. do I need anything like angular-seed or angular-sproud? OR these frameworks are only for javascript only applications?
AngularJS is a frontend framework, angular-seed and angular-sprout are just examples of how it used, quick start projects.
In your case, the app will most likely use Spring and Java on the backend and have so called one page dynamic JavaScript frontend built in AnglularJS.
Have a look at Rob Harrop's demo project that integrates both technologies, I found it to be really helpful.
Spring MVC REST and AngularJS
I was in the same predicament some time back. The short answer is depends!.. you do not need Angular-Seed to front-end a Java EE app. But you do need some starting point. The problem is that AngularSeed is not really a servlet that can be served up as an SPA.
On the other hand, if you would like to build a front-end completely decoupled from the server then maybe AngularSeed will work for you.
I've written about this here
I began with AngularSeed and was kind of disillusioned. Using a Servlet to serve up the Angular SPA is so much better.
Related
I'm a newbie in web application development and try to explore some technologies. I have some (very) small experience with Spring-MVC and AngularJS. Recently, I've started to learn Thymeleaf.
Having some really basic knowledge of these technologies, I'm trying to figure out whether and how to use them jointly.
I know there are combinations like REST API as a Spring-MVC controller + AngularJS as a front-end technology that consumes the given data. And that's might be enough for your Single Page Application. But what about applications consisting of many pages which should reuse some components (ex. navbars)? And what about including security mechanisms in those applications?
I've just got to know that there exists Thymeleaf which seems to be a decent template engine. So far I've only used it to create some templates for my HTMLs, but I've heard there are many more appliances - like taking advantage of its nice integration with Spring.
I'm going to create web application consisting of a few pages with security mechanisms (registration, logging etc.), database integration and a lot of user interaction. It would be sort of order system.
Does it make any sense to mix front-end technology like Angular and back-end's Thymeleaf, especially in my case?
I've seen nice post here, but still need some clarification.
I would suggest jhipster. Recently I wrote application with this API and I think its one of the best startup for application with back-end based on SpringMVC and front-end with AngularJS. You can easily generate template from command line which is fully editable
I'm in the "technologies selection" phase of a small, single-page web application that will be heavily-based in AJAX, and which will report to a Java backend.
In a previous question I posted several weeks ago, the SO community at large felt strongly that I would be better off going with a Spring MVC-based web app than with something in JSF. Since Spring is request-oriented, and JSF is component-oriented, it would only make sense to use Spring for something that is going to be getting a lot of asynchronous requests.
If I were going the JSF route, then my next set of decisions would be whether or not to use so-called UI component libraries for the view technology, such as PrimeFaces, IceFaces or MyFaces.
So, I'm wondering: Does Spring MVC have anything similar to, say, PrimeFaces (or its likes) for creating the view component for my page(s)? I know its not component-based, but I'm not all that familiar with Spring MVC's web platform and was wondering what are some de facto standards (if any) or typical technology stacks that Spring web developers use for constructing nice web pages.
And, if Spring just uses run-o-the-mill template engines, would something like Freemarker suffice?
I guess this is a "best practices"-type question for a budding Spring web developer.
Thanks in advance!
Typically, the value so-called UI components lies in how they keep track of user interactions on the server side by integrating with a stateful framework.
Since you have decided to go for a request oriented framework, it would make more sense to use some well-known client-side JavaScript libraries instead. Popular choices include:
Backbone.js – an MVC foundation for user interfaces
jQuery UI for some premade widgets (calendars, etc.)
If you want to go down a more complex route, but with a more desktop-like feel, Sproutcore
Finally, if you wish to avoid JavaScript, you can useGoogle Web Toolkit, which compiles Java to JavaScript and is supposed to have good integration with Spring.
Personally, if I don't need a lot of standard prebuilt widgets, I like Backbone.js + underscore.js + jQuery. I don't like Google Web Toolkit since it feels like writing a pidgin JavaScript, and at that point I prefer to write JavaScript directly.
Yes, JSF is component oriented and Spring MVC is request oriented.
I recommend you to have a look at Thymeleaf Template engine, which is a complete replacement for JSP Engine
....
Thymeleaf Features are:
It allows natural templating.
HTML5 support
Higher performance by utilizing in memory caching
Click here for more
Additionally apart from the things mentioned by Ludovico Fischer, if we consider the same question in now a days tech world than you can use one of the most power full thing of recent world : Angular. There are 2 sample scenario's.
If your architecture is full client side: The integration is very natural for it. Spring MVC expose your service as a REST (JSON / XMl ... ) and your client application with Angular JS consume your JSON. Here the war application (Spring mvc ) must be deployed in a Servlet Container (Tomcat) and your client application can be deployed in the same server or in another server Nginx , Apache etc..
If you want to keep page generation in the server side and only use AngularJS for some nice DOM manipulation so your code must be deployed in the same war (WEB-INF). Mixing the two approachs is not always a good idea. You can try thymeleaf to stay in server side page generation.
Thus in this way you can have simultaneously the cool featuresof angular like templating, testability and clean view code.
Here is another approach (Not JSF) to let Spring MVC to work with ZK UI components - Rich Web Application with Spring MVC CRUD Demo
In that article, it used Spring MVC controller to communicate with ZK UI components. (all in Java code)
I am in the process of beginning development of a web-based user interface and am looking for some expert advice on the right direction for my project.
Since our server-side is to be developed using Java, I am planning to use scriptless-JSP and an MVC framework called FrontMan. FrontMan is a lightweight Java-based MVC framework similar to Struts. I have played around with it and like it. The plan is to use scriptless-JSP assisted by JSTL and JSP tag files. I worked out some prototypes using these technologies and I liked what I had.
Now I am in the process of planning out the client-side stuff. My plan is to use JavaScript, jQuery, jQuery UI to build the front end. During my investigation I came across a very nifty JavaScript MVC framework named JavaScriptMVC. I have to say I really like it. It is not just a client-side MVC framework, but also includes tools for testing, documenting and deploying.
The more I engage in figuring out the client-side plan, I realize that I think this is going to be more of a JavaScript (client-side) app. I am leaning towards doing as much of the work in JavaScript rather than on the backend via Java. The backend will exist mostly for communicating with the database and responding to requests from the client (frontend) for manipulating or retrieving data.
I am rather new to RESTful web services, but in the little I have read about them, I think this might be a good direction to take this project.
I am wondering how I can employ both an MVC framework and REST framework together? Do they make sense together?
I am using Jetty as my web server, so I think that lends itself to using Restlets...?
Anyway, I am not sure how much sense I am making in this post, so I will stop it there for now.
As the previous poster mentioned, it makes perfect sence. MVC let's you separate concerns such that you can keep your application logic separate from your presentational logic.
Your REST controller serves the request you need, populates the model, and exposes it in a REST like manner, typically by returning an xml view to the user. This can be aided by a number of libraries such as xstream, jaxb, castor, xmlbeans, which all provides routines to marshall an object into xml.
Exposing a REST API on the server-side will be a perfect fit for your JS front-end. Your resources will have to expose JSON representations. You will even be able to reuse this web API from other clients such as mobile phones.
As the lead for the Restlet Framework, I can only recommend it for this purpose. Integration with Jetty is very stable :)
Cheers,
Jerome
A quite extensive discussion on this can also be found here:
Separate REST JSON API server and client?
For me it was very helpful.
Yes! It makes sense as Johan Sjöberg said! You can use Spring MVC for example. I like it a lot and think it is very simple and easy to learn. You have an example here.
By the away, for the frontend maybe you would like to check this presentation.
I'm looking for a java AJAX framework which I can include into my existing webapp. I've found sweetDev RIA . Are there such other frameworks which I could look into it?
I'd take a look at DWR: Direct Web Remoting. It allows you to directly call Java (web services) from JavaScript in a really intuitive way.
Last couple of years, I have been developing rich looking web applications with icefaces. It is pretty cool, ajax is buit-in and it blends very well with jsf. If you use icefaces, javascript is not required anymore. In our web project we use javascript only in couple of places.
Here is an excerpt from icefaces homepage: "As a leading open source Ajax framework, ICEfaces is more than a Ajax JSF component library, it's an J2EE Ajax framework for developing and deploying rich enterprise applications (REAs). With ICEfaces, enterprise Java developers can easily develop rich enterprise applications in Java, not JavaScript."
I suggest ExtJS (with jQuery underneath), but you might prefer GWT. I think it's easier for Java programmers who are seeking to wade slowly into JavaScript waters.
I would really check out extjs.com. It is the most feature complete javascript component library I know of. The components are fast, have beautiful default styling, and the API is very powerful. AJAX support is also excellent. Most of my current web development include extjs in some way.
It's very easy to use this library with java. Most of the time, I just have some server side component that returns data in JSON.
There is also ExtTLD; a tablib wrapper for extjs. I have never used it myself, though.
Google Web Toolkit ( GWT )
you can also use Apache's 'Myfaces' project http://myfaces.apache.org
Its a JSF implementation, and also has components with in built ajax capability.
You can try SweetDevRia, it's possible to add ajax in your application without writing Javascript. You only need to use JSP tags
I'm coming to Java from C# & ASP.NET MVC, I'd love to find an equivalent in the Java world that I could use on the Google App Engine. I've already started to have a play with FreeMarker and even made the first steps towards writing a very simple framework. Ideally I wouldn't have to do all the hard work though, someone must have done this already! So my question is - what frameworks are there out there that would be familiar for me coming from ASP.NET MVC and I could use them on Google App Engine for Java.
The key things I'd want are:
Simple Routing - /products/view/1 gets mapped to the view action of the products controller with the productid of 1
Template Engine - some way of easily passing 'ViewData' to the view, and from the view easily accessing it, ideally I'd love to avoid anything that is too XMLy (thus why I like FreeMarker).
I am currently working on a Google App Engine app using Spring MVC. It is a lot more mature than ASP.NET MVC so you shouldn't be disappointed. As an added bonus you have the whole IoC power of Spring.
For the view layer I am trying out Velocity. It is pretty simple but I have yet to decide if I will prefer it over JSPs. I had a brief look at FreeMaker but didn't like what I saw. If you want to stay away from XML'y JSP templates than I recommend you give Velocity a spin.
The only problem I have had with Spring on GAE is file uploading. The MultipartResolver implementations both rely on a temporary file directory. After writing my own implementation I'm back to seamless uploading of files in my models.
There are a couple of MVC frameworks that you should consider (that's what I'm doing now). Initially, I went with Spring MVC (3.0) and the cold start on GAE is horrendous! It takes about 10 seconds to start (and I'm not even using anything complex, like spring security, etc), so I need to use a cron job to keep it alive. So I don't recommend that you use Spring at all on GAE.
Take a look at the following frameworks:
VRaptor
Slim3
Google Sitebricks
As for the templating, I use Sitemesh -- used it for quite a while now, so don't see a need to switch.
Hope this helps!
Play Framework would fit the bill. It's a modern MVC framework for Java and has a Google App Engine module to provide compatibility. See http://www.playframework.org/modules/gae.
Another benefit to using Play would be portability. You can deploy Play using its built-in webserver (optionally behind apache for caching, load-balancing, etc) or you can bundle as a .war file for deployment to the many Java application servers (Glassfish, Tomcat, ...).
I also have a strong preference for Freemarker. I suggest that you look at the Induction framework, its template engine is pluggable but the default support is for Freemarker. Induction is a light-weight and fast MVC framework (7.7K lines) but has many features absent in the major MVC frameworks, such as:
dynamic reloading during development when you change the controllers, views or models
file uploads so simple (not much different that a string input)
no configuration required for controllers
capability to analyze dependencies between your Models, Views and Controllers using your IDE
regular expression based URL mappings
best support for managing redirects of any MVC framework
As for the file upload issue raised by #pjesi, Induction allows you to set the size threshold at which files getting written to disk. If this is set large enough it should not try to write any files to disk.
Check out the getting started tutorial here: http://www.inductionframework.org/getting-started-tutorial.html
JavaServer Faces (JSF) I've heard is similar to the microsoft MVC framework. (I use JSF but have never used .NET MVC). And I believe JSF 1.1 works fine on Google App Engine, and I suspect that the newer versions of JSF will work if you stick to using XHTML instead of JSPs as the templates. There are also some nice libraries which let you leverage an AJAX interface on the JSF framework, RichFaces is a popular one.
Check out
JavaServer Faces on sun.com
and also
JBoss RichFaces