write a mvc framework to learn struts - model-view-controller

Hi:
I am learning struts,however I was often confused by its configuration,sometimes I do know clearly why.
SO I wonder if there is any idea to write a simple mvc framework which need not have to be prowerful enough,just make me know more about the steps the struts-like framework do.
Any ideas?

MVC is really a paradigm, and if you simply want to get up an running with an mvc framework, you can look into groovy on grails (which is built on spring mvc) and should be easy to understand and quickly configure
If you want to be adventurous, you can play with django, which is the python framework for building web apps, though they prescribe to the mvp (model view presenter) pattern.
Additionally, http://www.springsource.org/roo may be a good fit for pure Java fans

Also, there is the Struts 2 tutorials which help.
http://struts.apache.org/2.x/docs/getting-started.html
I enjoy the "Bootstrap tutorials" which is a link at the bottom of the aforementioned page.

Related

Spring MVC view technology: what to choose?

I want to create web-site with Spring back-end, but I can't choose what view technology to use: JSP, Velocity, or I should try to integrate JSF with my app. Which of this technologies is the most popular?
Looks like that JSP is a quite deprecated technology, but I hasn't found a proof of this thesis yet. Should I learn JSP, or try some another framework?
I´d use JSP+JSTL+Tiles, but mainly because everybody knows them. I could consider to use Freemarker or Velocity (Specially the first). However, I think Spring MVC and JSF are technologies that overlap, and using them together could be useless and dangerous.
I recommend you to take a look at this: http://docs.spring.io/autorepo/docs/spring/3.2.x/spring-framework-reference/html/view.html
And also at this: http://ihatejsf.com/

What the difference between struts2 and spring MVC

I am learning Java EE and wanna build up a complete management system for a restaurant. Now I am confused what presentation layer should I use for my RMS because I heard that the struts 2 is one of the best UI layer but, the thing is, if I am using spring for my business logic layer then I can use the spring MVC can't I? By the way, I am really interested to build a complete application which is follow the multi-tier architecture.
Yes, of course you can use Spring MVC.
You can use Struts 2 if you'd like as well, because Spring integrates with it nicely.
But I don't see any reason why you'd want to do that. The person who told you that Struts 2 is
one of the best UI layer [sic]
is misguided. If you compare it to Spring MVC, you'll see that the two are based on similar ideas, but Spring improves on Struts. JSF has superceded Struts as the default Java EE web view technology, so it's not even considered "best" by the Java EE standard.
Stick with Spring. You won't be sorry.
I will not blame struts 2, indeed it's a great product, I work with it every day. But in my experience spring MVC is a lot simpler and clearer. This doesn't mean you don't get as much features.
Try both, and you'll see what I mean.
Tell us which one you choose!

Choosing Presentation layer for spring application?

i was using JSP and YUI with spring applications
and i want to use a new presentation layer like IceFaces or GWT or any other good one
but i am confused what to choose
i need to make a good looking view, and the technology must have a good support/samples, and easy to use, commonly used with spring, please advise, thanks.
I don't have enough experience in IceFaces, but GWT is really easy, rapid and full ajaxian. Also the SEO issues can be handled in GWT.
Although a bit old, check out:-
http://woork.blogspot.com/2009/01/10-beautiful-web-ui-libraries.html

Spring roo Vs (Wicket and Spring)

Spring roo is new framework and I found it very interesting. I have been working on web application for last 3-4 years and Always found JSPs are hard to maintain across teams if everyone is not disciplined enough about separation of markup and serverside logic. I have used JackBe/BackBase in last projects and I enjoyed xml templates working as views. This was much better than JSPs. But I couldnt automate webtests through selenium for backbase.
I would be surely using Spring MVC (-view), Hibernate on the backend. I found Wicket as good alternative. Have you used wicket along with Spring and what was your experience?
First, Spring Roo is a code generator tool (similar to Grails commands system):
(source: springsource.com)
Second, Spring Roo applications currently use Spring Web Flow for the view and Spring for the glue.
So, while you can compare (Spring Web Flow + Spring) and (Wicket + Spring), the later combo doesn't offer anything comparable to Roo out of the box (maybe AppFuse or AppFuse Light but you didn't mention them and they are third-party projects).
In other words, I don't think that "Spring Roo vs (Wicket and Spring)" makes sense.
Our current project uses Spring and Wicket, we have always used Spring but switched to Wicket a year ago. Few advices:
Get the "Wicket in Action" book.
The user mailing list is very helpful.
Make sure you understand Wicket's programming model especially the session serialization related stuff (the book does not help enough in this area IMHO).
Wicket is good at building stateful pages, it requires more work to build stateless pages.
There are some good UI widgets available like inmethod DataGrid.
It's easy to inject your Spring beans in your pages or components.
Spring Roo is still in beta (1.0 M2), so it may be a little early.
We also considered Tapestry 5 but we thought it was a bit young a year ago.
Spring Roo 1.0.0 (GA) has now been released, complete with around 100 pages of documentation.
If you're wondering about what Roo is and why use it, I recommend you take a read of the introductory chapter of the reference guide. It covers this and more.
#Antony, GWT support is a major priority for Roo and something I am currently working on. Expect to see some interesting integration in the very near future.
I was at the SpringOne conference in Amsterdam earlier this year when they announced Roo. My impression (and that of my colleague who was there) was that Roo was good if you were generating a web-based CRUD application every few weeks - they pitched it as the pure Java version of Grails (which is RoR for Java).
Didn't look interesting for anyone else - but that's just an opinion.
I've seen a demo of Roo a few months ago. It looks a lot like Grails (another spring technology), except that instead of creating artifacts for the Groovy language, you create them for Java.
Still it enforces good practice and makes you apply the MVC pattern in a clean way.
Personally, the demo didn't make me change my preferred toolkit (Grails), but that's because I can achieve faster results with Groovy (parsing xml for example is much more "painful" in Java than in Groovy). Also, with Grails I can see the changes I make instantly without having to recompile my entire project and relaunch the application each time I want to see the results.
Last but not least, in Grails you have tons of plugins to make fancy Ajax websites (ZK for example, if you want to avoid Javascript, but there are plugins for GWT, Yahoo, Dojo, etc...).
So, if you don't want to learn Groovy (which is not too difficult if you already know Java), Roo is the way to go to build clean web projects with all the power of Hibernate and Spring.
I hope this helps...
Why use Roo when one can build something w/ GWT and end up w/ a far richer better outcome and without the constraints of Roo and its architecture. Spring Web Flow is yesterdays technology.
It completely depends on what your requirements are. If it's a small site then Component Oriented frameworks like GWT or Wicket are a must as they make things really easy.
How soon with Roo support GWT? I think that the use of GWT by Roo makes it a huge win for GWT and Roo!
Roo and GWT are available today in pre-release form. In my opinion, definitely not ready for prime time.

Are all MVC platforms the same?

In the future I will be working with MVC with java/j2ee,hibernate,and more, but for now I have asp.net, php, python, ruby, etc. If I learn how to use MVC asp.net or MVC with a php framework, or RoR, will that help me with the Java version? I don't want to wait until I start the java project before I start really learning how to use MVC, but if the .net or php versions of mvc are so different that it will be a major relearning, then I might not use the non-java mvc frameworks.
In short, is learning MVC on one platform good for learning it on all platforms? I realize the tools and languages will be different, but my question is for general knowledge.
I hate working on things in a "special" way for a one time project that will show no future benefit.
Thank you.
MVC is all about splitting your application into 3 major parts. The model which contains most of the code that interacts with your database, the controller which accesses the model and gets the data it needs which then gets passed to the view which renders this for the user to see.
No matter which technology/framework you choose this basic principle will remain and only the technology used behind it will change.
For example if you went the PHP route and choose symfony as your web framework you would be using Doctrine or Propel as your model/ORM. If you used JBoss Seam you would be using Hibernate/JPA as your ORM and EJBs as your controllers.
Even though these 2 frameworks follow the same rules when it comes to separating logic from design they also require you to learn very different concepts to utilize them correctly.
For instance in JBoss Seam, the framework relies heavily on your knowledge of scope and stateless and stateful session beans where in symfony there is no such concept (sort of).
So whatever route you choose, there is still much to learn after you've mastered the concept of MVC.
MVC is a basic software architectural pattern. It's just an abstract concept. Its specific implementations will differ based on the language and platform you are using (as does everything), but the basic concepts remain the same.
So in a word: yes. Learn what MVC means as a concept and you'll be able to transfer that knowledge between platforms and technologies.

Resources