Solved

JSF MVC Sample Application

Posted on 2006-07-12
9
6,787 Views
Last Modified: 2013-11-24
I've read a LOT of documentation on the MVC model and how it is implemented in JSF, but I would like to see a small sample web app that uses JSF and the MVC arcitecture so that I can poke around the code and get a good sense of it.

Please list any places I can find such samples.
0
Comment
Question by:mmarksbury
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 24

Expert Comment

by:slyong
ID: 17096217
Hi mmarksbury,

> but I would like to see a small sample web app that uses JSF and the MVC arcitecture so that I can poke around the code and get a good sense of it.

JSF "is" an MVC framework, so I am not very clear by what you mean that you would like to see an app that uses JSF and the MVC arcitecture.  Have a look at the discussion here http://forum.java.sun.com/thread.jspa?threadID=563379&messageID=2782685 and there are a few tutorials about using JSF as MVC framework (if I understand you correctly):

http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html
http://www-128.ibm.com/developerworks/library/j-jsf1/
http://www.jsftutorials.net/
0
 
LVL 7

Author Comment

by:mmarksbury
ID: 17096279
Well, you can easily use JSF without following an MVC architecture.  For example, I could put all business logic and data access in my backing bean, or even on my JSP.  I would like to some sample code of JSF as MVC in action that follows some standards.

In short, I'm looking for a good model.
0
 
LVL 24

Expert Comment

by:slyong
ID: 17096300
Hi mmarksbury,

yes you are right, have a look at the first link from javaworld, the JSP Model 2 is a very good example of MVC.
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17096864
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Accepted Solution

by:
anumalas earned 250 total points
ID: 17097270
Hi

These are the best links:

First link provides all MVC 2 pattern support JSF implementation for Classifields.

http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.etools.webtools.tutorial.doc/topics/intro.html

Second one  will provide IDE and some tutorials to create jsf applications

http://www.exadel.com

Hope this will help you to build good JSF knowledge :)
0
 
LVL 7

Author Comment

by:mmarksbury
ID: 17100645
I still haven't seen a good model of a JSF built on the MVC architecture.  I am looking for a sample application, nothing big, but a working sample that I can look at and learn from.  I know JSF already, and I understand the MVC model.  I simply want to poke around at an application that has already been built.  Anyone have a link to such a sample application?
0
 
LVL 27

Expert Comment

by:rrz
ID: 17104733
>I still haven't seen a good model of a JSF built on the MVC architecture.
I am not an JSF expert.  But, for the sake of this dicussion,  I propose a simple app.  
 the model
----------------------------------------------------------------
package myPack;
public class UserBean{
                 private int count;
                 public UserBean(){
                                   count = 0;
                 }
                 public int getCount(){
                           return count;
                 }
                 public void addOne(){ count++;}
}
-----------------------------------------------------------------------------------
the view  
-------------------------------------------------------------
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<HTML>
    <HEAD> <title>MVC</title> </HEAD>
    <body>
      <f:view>
           <h:form id="AddOneForm" >
                 <h:outputText id="count" value="#{userBean.count}"/>  
                 <h:commandButton id="addOne" value="addOne" action="#{userBean.addOne}"/><p>
           </h:form>
      </f:view>
    </body>
</HTML>
---------------------------------------------------
in  faces-config.xml
-----------------------------------------
<faces-config>
  <managed-bean>
    <managed-bean-name>userBean</managed-bean-name>
    <managed-bean-class>myPack.UserBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
  </managed-bean>
</faces-config>
0
 
LVL 7

Author Comment

by:mmarksbury
ID: 17131300
It seems to me that there is a lot of descrepancy out there as to what in JSF is the Model and what is the View/Controller...hence, the reason for my question in the first place.

In many tutorials and even in answers within this question, I see reference to backing beans as the model.  It seems to me that it would play out more like this.  What do you all think?

Model:
----------------
Class library or classes containing business objects that reflect your business process needs including classes and methods that handle data access.

View:
----------------
The JSF's and UI components that actually present data on the page.

Controller:
----------------
A combination of various things including Backing Beans that control the flow of the application.  For example, a faces servlet in combination with a backing bean sending a response.
0
 
LVL 3

Expert Comment

by:anumalas
ID: 17133450
yes it  seems like that

but

JSF is like a swing application from server side :)

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now