Professional Documents
Culture Documents
Faadoo Engineers. Com
Faadoo Engineers. Com
Part 4
FaaDoOcom
Engineers.
FaaDoOEngineers.com
Day 4 Coverage
FaaDoOEngineers.com
Module 1: Design pattern
FaaDoOcom
Engineers.
FaaDoOEngineers.com
Module objectives
FaaDoOEngineers.com
What are patterns?
FaaDoOEngineers.com
Why use patterns?
FaaDoOEngineers.com
Presentation tier patterns
The presentation tier patterns deal with the common problems occuring in the
presentation layer such as - view management and navigation, processing of
dynamic business data, efficiently accessing the read-only data, and so on.
The following are the common Presentation tier patterns:
– MVC
– Intercepting Filter
– Front Controller
– View Helper
– Composite View
To SME:
– Service to Worker
Please define or describe Presentation tier pattern (in general).
FaaDoOEngineers.com
Presentation tier patterns: MVC: Forces
There is a need for centralized controller for view selection and navigation
(Model 2) based on user entered data business logic processing client type.
Common system services are typically rendered to each request, so having a
single point of entry is desirable.
– Examples include authentication, authorization, and logging.
– It can leverage filter pattern.
FaaDoOEngineers.com
Presentation tier patterns: MVC: Solution
FaaDoOEngineers.com
Presentation tier patterns: MVC: Class Diagram
Consumer Controller
To SME:
Please provide a brief description of the diagram.
JSP Controller Servlet Controller
FaaDoOEngineers.com
Business tier patterns
FaaDoOEngineers.com
Business tier patterns: Business Delegate: Forces
FaaDoOEngineers.com
Business tier patterns: Business Delegate: Solution
FaaDoOEngineers.com
Business tier patterns: Business Delegate: Class diagram
Lookup service
To SME:
Lookup
Please provide a brief description of the diagram.
FaaDoOEngineers.com
Business tier patterns: Service Locator: Forces
FaaDoOEngineers.com
Business tier patterns: Service Locator: Forces (continued)
FaaDoOEngineers.com
Business tier patterns: Service Locator: Implementation
FaaDoOEngineers.com
Integration tier patterns
The integration tier is a boundary tier and interacts with different external
systems for data exchange.
Common Integration tier patterns:
– Connector
– Data Access Object
– Service Activator
To SME:
Please define or describe Integration tier pattern (in general).
FaaDoOEngineers.com
Any questions?
FaaDoOEngineers.com
Module 2: Introduction to JavaServer
Faces (JSF)
FaaDoOcom
Engineers.
FaaDoOEngineers.com
Module objectives
FaaDoOEngineers.com
What is JSF?
FaaDoOEngineers.com
Why JSF?
FaaDoOEngineers.com
Why JSF? (continued)
FaaDoOEngineers.com
JSF - A UI Framework for Java Web Applications
The UI created with JSF technology runs on the server and is rendered back to
the client in a mark up language that is appropriate to the client.
Client Server
Access page
HTTP Request
Browser UI
Renders HTML
HTTP Response
FaaDoOEngineers.com
JSF features
FaaDoOEngineers.com
Roles – JSF Application Development
FaaDoOEngineers.com
The JSF lifecycle
Redisplay requested
Faces
Response Update
Render Invoke
Model
Response Application
Values
Conversion errors
Validation errors
FaaDoOEngineers.com
The JSF lifecycle (continued)
Response Complete Response Complete
Faces
Request
Reconstitute Apply
Component Request Process Process Process
Tree Values Events Validations Events
Render Response
Update
Render Process Invoke Process
Model
Response Events Application Events
Values
Faces
Response
Conversion errors
Validation errors
FaaDoOEngineers.com
What goes in a JSF Application?
FaaDoOEngineers.com
What goes in a JSF Application? (continued)
FaaDoOEngineers.com
A simple JSF application
Create a simple web application called HelloJsfApp that takes a user's name and
email ID and returns success on submission of form. The button in the form
directly specifies a return condition.
Following are the steps required in developing a simple JSF application:
Create a JSP page greeting.jsp using UI components and core tags
Create a JSP result page response.jsp that displays “Welcome to JSF!”
Set up Page Navigation in the application configuration resource file
Configure and Run the Application
FaaDoOEngineers.com
Creating the pages
FaaDoOEngineers.com
Creating the pages using UI component and core tags
FaaDoOEngineers.com
Adding view and form tags
FaaDoOEngineers.com
Elements inside h:form tag
FaaDoOEngineers.com
Defining page navigation
FaaDoOEngineers.com
Configuring and running the application
FaaDoOEngineers.com
Any questions?
FaaDoOEngineers.com
Module 3: UI Component Model
FaaDoOcom
Engineers.
FaaDoOEngineers.com
Module objectives
FaaDoOEngineers.com
UI Component Model
JSF User Interface (UI) components are configurable, reusable elements that
compose user interfaces of JSF applications. A UI component can be simple, like
a button, or compound, like a table, which can be composed of multiple
components.
FaaDoOEngineers.com
UI Component Model (continued)
FaaDoOEngineers.com
UI Components
FaaDoOEngineers.com
Standard JSF UI Component Hierarchy
FaaDoOEngineers.com
UI Component Trees
UI components in JSF are composable. In other words, you can nest one
component within another to form more complex client interfaces. These
compositions are referred to as component trees in JSF.
Here is an example of a component tree:
A form component is a root component and inside it there are input components
and a command button that submits the contents of the input component.
FaaDoOEngineers.com
Typical JSF Component Tree
View
Form
FaaDoOEngineers.com
Component Rendering Model
FaaDoOEngineers.com
RenderKit
To SME:
In the second bullet point, is it HTML render kit or HTML RenderKit?
FaaDoOEngineers.com
The UIComponent tags
FaaDoOEngineers.com
UICommand Tags
Each JSP custom tag defined in the standard HTML render kit is composed of:
– the component functionality (defined in the UIComponent class)
– the rendering attributes (defined by the Renderer class)
For example, the two tags below represent a UICommand component
rendered in two different ways.
– commandButton tag is rendered as
– commandLink tag is rendered as Back
FaaDoOEngineers.com
Using JSF Tag libraries
JSF technology provides two tag libraries: html_basic TLD and jsf_core TLD
JSF html tag library
– Defines tags that represent common HTML user interface components.
JSF core tag library
– Defines standard JSF core tags
– Independent of a particular render kit
FaaDoOEngineers.com
Types of Core Tags
The core tags include those related to expressions, flow control, and a generic way to
access URL-based resources whose content can then be included or processed within the
JSP page.
– Event handling tags
– Attribute configuration tag
– Data conversion tags
– Facet tag To SME:
– Localization tag
Please define or describe Core Tags (in general).
– Parameter substitution tag
– Tags for representing items in a list
– Container tag
– Validator tags
– Output tag
– Container for form tags
FaaDoOEngineers.com
Steps in JSF Application Development Process
FaaDoOEngineers.com
Any questions?
FaaDoOEngineers.com
Module 4: Managed beans
FaaDoOcom
Engineers.
FaaDoOEngineers.com
Module objectives
FaaDoOEngineers.com
Managed Beans
FaaDoOEngineers.com
Developing managed bean
FaaDoOEngineers.com
Developing managed bean
FaaDoOEngineers.com
Developing managed bean (continued)
FaaDoOEngineers.com
Adding managed bean declarations in faces-config.xml
<managed-bean>
<managed-bean-name>UserBean</managed-bean-name>
<managed-bean-class>bean.UserBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
FaaDoOEngineers.com
Referring to beans in input form
<f:view>
<h:form>
<p>Enter your details: </p>
<p>Name: <h:inputText value="#{UserBean.name}" /></p>
<p>Email: <h:inputText value="#{UserBean.email}" /></p>
<h:commandButton value="Submit" action="submit" />
</h:form>
</f:view>
FaaDoOEngineers.com
Outputting bean properties
Example:
<f:view>
To SME:
<h:form>
Please identify the bold text in the success.jsp code.
<p>Your name is: <h:outputText value="#{UserBean.name}" /></p>
<p>Your email is: <h:outputText value="#{UserBean.email}" /></p>
</h:form>
</f:view>
I have removed the code snippet as the example is already given on the slide.
FaaDoOEngineers.com
Any questions?
FaaDoOEngineers.com
Session summary
FaaDoOcom
Engineers.
FaaDoOEngineers.com
Summary
FaaDoOEngineers.com
Summary (continued)
What is JSF?
FaaDoOEngineers.com
Summary (continued)
JSF life cycle is split up into multiple phases to support the sophisticated UI
component model.
JSF has an event-driven nature.
The combination of components that make up a specific user interface screen
is called a view in JSF.
JSF UI components are configurable, reusable elements that compose user
interfaces of JSF applications.
FaaDoOEngineers.com
Exercise
FaaDoOEngineers.com