Solved

JSF MVC Sample Application

Posted on 2006-07-12
9
6,826 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
Technology Partners: 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 8

Expert Comment

by:kaliyugkaarjun
ID: 17096864
0
 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb wildfly example 2 75
jsp login check 12 54
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 78
Where to place postgres JDBC driver jar on tomcat 8 31
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

730 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