Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JSF MVC Sample Application

Posted on 2006-07-12
9
Medium Priority
?
6,958 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
anumalas earned 500 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 28

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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

705 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