Java Equivalent for ASP.NET MVC Areas - java

Areas, in ASP.NET MVC, are handy for breaking a site into smaller, manageable components at a higher level than controllers. They are like mini-MVC pieces within a web application.
Is there an equivalent concept in any Java MVC framework to ASP.NET Areas?
If not, are there any suggestions on best practices when emulating their functionality in a Java MVC framework?

Try Spring MVC. This may be fulfill your wish.

Look at JSP Tiles and Velocity Templates. Tiles should look similiar to Areas.

Take a look on this Web Framework for java: playframework

As such, Java EE does not provide an out of box solution based on MVC but there are many OpenSource projects that have created a solution which implement a MVC framework - try the latest Spring and Struts versions.

Related

JSF(view) + Spring MVC bad choice? Even after JSF being an official EE specification, any replacements?

I am starting a new pretty big webapp and I am using Spring MVC for complete MVC architecure and I really don't want to change that. On top of that I am looking for a view technology and finally closed with JSF as JSF/facelets is in official EE specification which means they will be the future. Plus prime faces looks promising in acheiving good UI. I know JSF is a MVC framework and I just want to liverage its view part to reduce the development time and at the same time acheiving good and flexible responsive UI
But I went through several posts on StackOverflow itself which prohibits the use of Spring MVC + JSF. E.g, this one
Using JSF as view technology of Spring MVC
This question was answered in 2011 and now new Java EE specification also got released and many changes has happened. Is this point still stands that we should not use JSF+Spring MVC? If it is true, then what are the replacements. One option that looks good for me is Thymeleaf, but only thing that is troubling me is that will it be a good idea to neglect an official specification?
JSF can probably be integrated (I'm not very sure, see the links at the end of my answer) with Spring MVC but it does not look a very good fit to me.
Primarily since JSF is component based, while Spring MVC is action-based. In Spring MVC, the controllers do the processing and can pass the results to anything that renders the view (jsp, html, thymeleaf, apache tiles etc.). Thymeleaf is a good option and I like its approach to templates.
Other alternatives I would suggest to look instead of JSF:
JS frameworks:
I personally prefer this for my projects and there are tons of options to choose like jQuery/jQuery UI, ExtJS etc. for creating you views. You can combine these and make their elements work with fluid frameworks like Bootstrap so that they behave nicely on all screens sizes (not sure how PrimesFaces/RichFaces components behave on all devices)
Frameworks that compile to JS:
Here you have two good frameworks to choose from - Vaadin and GWT. I've used only Vaadin and not GWT so will not comment much on it. Choose this if you don't want to directly fiddle with javascript.
It is not true that only if you use the official Java EE spec you can be in sync with the future. HTML5, JS frameworks etc. are as much the future as JSF is, if not more! Ofcourse JSF of late looks good too (I have not made any production code with it yet, nevertheless have explored it in hobby projects) but you are better off using it on its own with PrimesFaces/RichFaces and not combine it with Spring MVC.
On a middle ground, you can use Facelets instead of Thymeleaf for templating views in Spring MVC. On the other side, you can use JSF with Spring DI, but as I said earlier don't mix JSF and its component libraries with Spring MVC.
Update: Just in case if you absolutely want to try it, here are some links:
http://spring-explored.blogspot.in/2011/11/using-jsf-with-spring-mvc.html
http://papweb.wordpress.com/2011/07/29/spring-mvc-3-jsf-2-with-maven-2-and-tomcat

Spring MVC with a rich client framework

I have several applications that are structured as follows
DataComponent
WebComponent
ThickClientComponent
WebServices
The DataComponent has all the functionality required to access the application's data so it contains the DAOs and the JPA entities. The other three modules are:
WebComponent - A spring MVC application that uses the DataComponent for data acccess
ThickClientComponent- A Swing application that uses the DataComponent for data access
WebServices - A SOAP based services that also uses the DataComponent.
All three projets have the DataComponent as a dependeny in their Maven POM file.
I would like to use a rich client framework like RichFaces, icefaces or primefaces as i need to be able to use the rich components are available in rich client frameworks (i.e. trees, panel, drag and drop etc).
I have looked around and i cant seem to find an example where a Spring MVC application uses a rich client platform. Is it possible? Are the rich client platforms a framework meaning that i have to use either Spring MVC or the rich client platform but not both?
The DataComponent module is spring based.
I suggest you to go for GWT. It is a very good rich client framework and it has a very huge set of components available including drag-and-drop. Also it provides the integration with Spring Framework. You can check out this and this links to know more about its integration.
I have also used smartGWT that is extension of GWT components in one of my project that has backend in Spring framework.
Hope this helps you. Cheers.
Maybe this module will sort you out:
http://static.springsource.org/spring-webflow/docs/2.0-m1/reference/spring-faces.html
You can try ext-js for creating your client side interface. It's heavily java script / ajax based, but that would probably meet your needs. It doesn't really care what your backed tech is, since it works entire through javascript and ajax.
Yess you can use Spring MVC with PrimeFaces but you have to use it with the spring JSF 2 implementation.
If you are thinking to use some faces framework definitely use PrimeFaces.
You could use SpringMVC with JSF but I also recommend to you not to use SpringMVC JSF implementation. Use insted the MyFaces JSF 2 implementation with Primefaces and then link the backing beans with spring.
From my experience this is the best.
But I guess any other options are fine too.

MVC or Rest or Both

I in the process of designing the server side of a web-based user interface that will be very JavaScript intensive.
I originally thought of going with an MVC solution, but now I am thinking I want to use a REST-based solution such as Jersey or Restlets.
Is this often an one or the other type decision or can they be a combined solution?
Thanks,
Mike
MVC is about how the inner side of your app works.
REST is about how your app "talks" with other apps.
You can combine them.
A lot of modern frameworks actually are MVC based and make implementing REST web services easy: Ruby on Rails, Java Spring Framework with SpringMVC , Django, Backbone.js
One of the best Java frameworks I've seen for building MVC webapps with the ability to support REST is SpringMVC. This blog post outlines the REST capabilities in SpringMVC since version 3.0. I've developed REST services using SpringMVC and Jersey, and they are fairly comparable.
They are patterns / solutions to solve different problems.
REST sanitises & simplifies addressing access to features of a web application, for users, client software, etc.
MVC provides a means to organise your application code, making it easier to maintain.
MVC is an architectural design pattern for the layers of your application.
The folder structure:
Models/YourClassModel.php
Views/Home/HomeView.php
Controllers/Controller.php
index.php
The application style REST is the Representational State Transfer of the application.

Java MVC Web development framework?

I want to develop a website with java but I'm absolute beginner in java web development.
I want to use a framework that uses the MVC pattern and Ajax.
I did some search and found that Spring or Struts are suitable but I'm not sure.
could you please recommend a framework?
Play Framework might be a good option because of its incredible simplicity.
I'd recommend Spring:
Developing a Spring Framework MVC application step-by-step
The Stripes Framework is also worth consideration and can be used along with Spring.
http://www.stripesframework.org
It's easy to use and easy to configure. Unlike Struts, which is fairly old hat these days.
There are a plethora of frameworks now and it's worth checking each one that will suit your needs. It's a personal thing and it's good that we're not all restricted to a few.
JRapid is very easy to use. You'll get a working application in minutes and it generates AJAX powered user interface.
I work with Spring Webflow - technology based on Spring MVC. Webflow is described in official help pretty well. Personally, it think Webflow is much more usable than bare Spring MVC, however there are always someone who disagrees.
Moreover Spring (not talking about MVC specifically) can be used outside of web projects, so it seems to me it is advantage of Spring.
Cannot say anything about Struts.
I would recommend GRAILS for fast rapid web application development, that includes scaffolding functionality and web page generation based on data models.
https://grails.org/learn
It is the fastest way for MVC developers.

Helping a beginner for java web application

I have pretty big background of .net, and I've decided that i want to port one of my websites to Java. (now with the asp.net MVC craze, I've figured I'd better learn a more mature approach to MVC).
i've downloaded eclipse (easyeclipse distro to be exact, and am ready and willing to develop my first website in java).
i've programmed j2me application before, so i know the language and some of the framework.
can someone guide me? any advice?
Although I'm not very aware of "asp.net mvc" is all about, I would suggest you to take a look at Spring it may be interesting.
Probably is too complicated at the beginning but when you get the concept it turns out very easy to follow.
Spring has 5 core modules ( which I don't remember exactly ) but they were like:
AOP
ORM
MVC
Core
( some other I'm missing here )
The MVC part uses a lot of annotations to make life easier. There's a very big community around Spring.
Here's an introductory article about spring.
Java has a ton of frameworks you can choose from. The technology stack that I use for my Java development is either:
Spring for IoC.
Hibernate for the data layer.
Struts2 for the MVC framework.
I have also swapped out spring and used Guice for the IoC.
Spring also has MVC, but I tend to like Struts2 better.
I'd recommend looking at Grails, it lets you become comfortable with all the java libraries and frameworks like Spring, SpringMVC, Hibernate, SiteMesh, and so on but gives you a much better DSL for web applications and much more concise code with the Groovy language (think of it as Java with dynamic typing, blocks, closures, and so on).
If you'd rather stick to pure Java I'd recommend looking at the Stripes framework and the following book:
http://pragprog.com/titles/fdstr/stripes
If you interested in web applications specifically, I would recommend using MyEclipse http://www.myeclipseide.com. Basically, this is a version of eclipse with all the web server integration and functionality built in. I've been using it for a few years and it's much easier to develop with than with plain vanilla eclipse. Depending on how much your going to use it, you have to decide whether the $55 annual subscription is worth it for you.
I'm a little confused. does spring framework actually a full blown framework? doesn't Java already have a framework? (by framework i mean all those misc libraries).

Categories

Resources