Today I have started JSF 2.0 after a long time I got some time to do something related to code.It seems JSF simpler if you know Struts 2.0 or Spring3.x .But JSF is more easier then Struts/Spring I would like to say.
Navigation in JSF is very impressive and very useful for security of your website as it does not show loaded/clicked action in URL.
I would be able to share my learning might be in some different part,Today I will going to give some introduction part on JSF ,also would like to share why we should go for JSF if we are having another framework like Struts and Spring etc.
Java
Server Faces (JSF) is result of a quest for …
•Building
dynamic web user interface in easy, efficient and maintainable way
•Building
web applications based on well-designed architecture to make it most
maintainable
•Now
in its version 2.0 ,it is indeed a standard way of building java based web
applications
I would like to define JSF in terms of below given bullet points-JSF (Java Server Faces)is
•Is a
Java EE Web application development framework
•Simplifies
web application development, using existing markup and servlet technologies as
its foundation
•Powerful,
component-based UI
•Development
framework that uses MVC2 design approach
Why Should we go for JSF can we define in terms of what JSF is offering us-
–Component-centric
API
•To
easily assemble Web application user interfaces
•Extensible
for specialized behavior
–Tag
libraries that enable operations on UI, by attaching
•Validations
(including Bean Validations)
•Type
conversion for input values
•Loading
resource bundles
•All
this for most simple to most complex container components
–Event-based
Java Bean model way of interacting with application data as managed beans
(XML/annotations)
–The
Faces Request Processing Life Cycle
•Handles
input standard/custom data-conversion/validation
•Update
server-side application data
–Easy
i18n of applications
–Flexible
API that allows pluggable rendering technology
•Render
HTML : A browser makes a request
•WML :
PDA/ WAP-enabled browser makes a request
•iPhone-specific
HTML : To serve content to an iPhone
–Unified
Expression Language (JSP EL + JSF EL)
•Built-in
Faceless/Advanced tinplating
•First-class
support for Ajax
•Composite
components
–Many
more features ….
Like other web framework present in market today JSF 2 also follows MVC-2 architecture
- Model- Managed Bean (i.e. UserBean pure POJO)
- View- Faceless (XHTML)
- Controller- Faces Servlet
![]() |
MVC 2 |
A very short example for a typical JSF-view would be the following:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<f:view>
<h:form id="mainForm">
<h:outputLabel for="enterName" value="Enter Name"/>
<h:inputText id="enterName" value="#{sayHelloPage.name}"/>
<h:commandButton value="Say Hello" action="#{sayHelloPage.sayHello}"/>
</h:form>
</f:view>
</body>
</html>
Note: To use <h:xx> and <f:xx> tags in code we are using additional xmlns(xml name space) given below-
For HTML tag in JSF - xmlns:h="http://java.sun.com/jsf/html"
For JSF Core tag in JSF - xmlns:f="http://java.sun.com/jsf/core"
To be Continued....
Comments
Post a Comment