This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF was Sun's answer to Struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF was Sun Watch "JSF was Sun New topic
Author

JSF was Sun's answer to Struts?

Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
Hi,

I'm very new to JSF (studying towards SCWCD).

When reading HFSJ, it talked about having a Front Controller design pattern, where a single servlet (controller) is tasked with handling all requests that come in.

It then talks about how Struts is a framework with this all built in, and I notice that the packages are from Apache.

Finally, I started reading about JSF through "JavaServer Faces Programming" by Budi Kurniawan (sadly out of date) and noticed a similar pattern - a single Faces servlet that requests are channelled towards.

If I were to say that "JSF was Sun's answer to Struts", would I be far out?


28/06/06 - SCJP - 69%, 05/06/07 - SCWCD - 92%, 28/02/08 - IBM DB2 v9 Fundamentals (Exam 730) - 87%, 18/11/08 - IBM DB2 v9 DBA (Exam 731) - 89%, 26/02/11 - SCBCD - 88%
John Blanco
Greenhorn

Joined: Jan 13, 2005
Posts: 20
Yes.

JSF is different than Struts. While it has the same sorts of patterns, JSF is a "Web standard" when it comes to building reusable UI components. Struts is a Web framework.

In fact, Craig McClanahan, the Struts designer, worked on the JSF 1.0 spec. And also in fact, you can use Struts within JSF.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

JSF wasn't so much designed to be a "Sun version of Struts" as it was to address some of the uglier aspects of Struts. And to make web app design more of the drag-drop-drool process it is in .Net.

Struts is technically known as a "Model 2" architecture. It's based on the old MVC paradigm, but no webapp can truly implement MVC, since a webapp cannot asynchronously update a view should the model be changed (HTTP is strictly client-request/server-response with no server "push").

The problem, as Craig McC himself pointed out, is that Struts requires a rather large number of loosely-interconnected objects in order to get simple things done. JSF reduces the number of objects. Instead of multiple action classes, a Form Bean, JSP and config wiring, you only have a simple JavaBean, JSF page, and config wiring. Some people have attempted to make a single action class handle multiple phases of the process, but that's even gnarlier than having multiple action classes.

And since the backing bean can constructed with no implicit knowledge of the container (unlike Struts objects, which have to be derived from Struts base classes), you can generally do unit-testing of JSF backing objects via straight JUnit-style testing without having to go through the cumbersome and time-consuming process of setting up and running a web container framework.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mark Garland
Ranch Hand

Joined: Nov 11, 2006
Posts: 226
Hi John and Tim,

Thanks for your replies - they make it a lot clearer.

Sounds as if I have a lot of reading still to do.

Thanks once again,

MG
Fabio Lin
Greenhorn

Joined: Oct 21, 2005
Posts: 12
JSF was Sun's answer to .Net Web development.
One of the JSF's key points is the productivity, area where Microsoft claims to be better with a WYSIWYG editor at Visual Studio.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

May I take another approace?

JSF was Sun's answer to the fact that the Servlet and JSP API was awesome, but it didn't provide a framework for developing applications. Things like state management, front controller design, error handling and MVC development was very much left up to the end user, and the Servlet & JSP API world was just begging for one.

It's a hypothetical statement, but I'd say that if Struts never happened, Sun would have still come up with JSF, because a unified development framework had always been needed.

Just my take.

-Cameron McKenzie
Xu Changfei
Greenhorn

Joined: Apr 24, 2007
Posts: 1
JSF's original target is support IDE's drag-style development,and now Jdeveloper and NetBeans is nice support to this.
and manual write JSF Code is easy too
......
George Stoianov
Ranch Hand

Joined: Jan 15, 2006
Posts: 94
JSF also has a richer life cycle within the default http mechanism of a request and a response, which allows the developer to perform different actions and plug in code in many places. It is a components based framework, which gives the ability of creating reusable presentation components in the same fasion that GUI applications have lifecycle and listeners attached for different events. Plus with the popularization of AJAX these components can/are even reacher, making web application not so mundane andboring but more responsive to user input. All of this still uses some of the nice stuff implemented in Struts, I mean the abstaraction of the view from the underlying system data etc., but it has a lot more breath in my mind, if you had to compare them I would say JSF goes a step further than Struts, you should be looking at Tapestry not Struts I think....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF was Sun's answer to Struts?
 
Similar Threads
Faces Servlet
Cannot use JSF tags inside JSP page.
MVC architecture
calling my servlet when jsf jsp submitted
Design Patterns in Struts