JSF road map (NI) • Clientside validation • Show problems – State example (search page don’t show back results) – Event Model (swing example , now tags data need to be parsed) – Validation model – We are doing a lot of low work ourselves (e.g. request.getParameter etc). Need a framework
46
Embed
JSF road map (NI) Clientside validation Show problems –State example (search page don’t show back results) –Event Model (swing example, now tags data need.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
JSF road map (NI)
• Clientside validation• Show problems
– State example (search page don’t show back results)
– Event Model (swing example , now tags data need to be parsed)
– Validation model– We are doing a lot of low work ourselves (e.g.
request.getParameter etc). Need a framework
Client Side validation Example
(NI)
• Discuss problems here• Problems with servlets and JSPs• Servlet and JSP
– Provide no direct GUI component support– No mechanism to manipulate stateful objects at the server– No way to auto-connect client events to server methods– Requires programming skill
• Low level details of HTTP and session• Undefined programming model – lots of tedious code
– State example (search page don’t show back results)– Event Model (swing example , now tags data need to be parsed)– Validation model– We are doing a lot of low work ourselves (e.g. request.getParameter etc).
Need a framework
Intro to Framework
• Framework vs. API
• Different existing framewroks– Struts
• Helps define a structured programming model (MVC), a validation framework and reduces tedious coding But…
– Adds complexity and doesn’t provide UI tags– Very Java programmer centric
– Tapestry– JSF
JavaServer Faces
A new face on application development in Java
JSF Architecture & Technology (NI)
Internationalization
Navigation
Type Conversion & Validation
Server Side UI Event Handling
Rendering Model
Model Object Integration
UI Component Model
A Set Of UI Components
A JSF Custom Tags
TechnologyArchitecture
APIs And Programming Model
Java Server Faces – Major Features (NI)
• Components– Allows creation of user interfaces from a set of standard, reusable
server-side components • Provides JSP tags to access those components
– Allows component rendering to support multiple markups and device types
– Provides a framework for implementing custom components
• Easier Programming Model– Transparently saves state information and repopulates forms when
they redisplay – Provides a mechanism for tying client side events to server side
logic / processing• Components available to scripts on server
– Contains mechanisms for validation and conversion– Separates presentation from logic
• Enables more functional “RAD” Tooling
JSF – Web Application Infrastructure (NI)
HTTP Request & Response Handling
Java, Session Mgmt, Lifecycle Mgmt, SecurityDeployment and Packaging
Extensible Template Mechanism
Template Reuse, Management And Layout
Resource Mgmt, Enhanced Error Handling
Pluggable Initialization Architecture
Layer Separation
Form Handling & Validation
Server Side UI Events & Data Conversion
Stateful UI Component Model
Automatic markup generation
Low
High
JSF
Struts
JSP & Servlet
Abstraction
What is JSF?
• A framework which provides solutions for
– representing UI components – managing their state– handling events– input validation– Data binding – Automatic conversion – defining page navigation– supporting internationalization and accessibility.
Enhanced Productivity for UI design (NI)
• Page level RAD
• Allows building web pages in a manner very similar to Visual Basic, PowerBuilder, or Domino Designer
– Provides a component model– Allows users to think about components,
events and scripting instead of the details of HTTP requests / responses
• Competes directly with MS .Net WebForms
UI Components (Standard)
Some of the standard JavaServer Faces Components
UI Components (Custom)
Some custom JavaServer Faces Components
UI Components (Open Source)
Some open source JavaServer Faces Components
UI Components (Third Party)
Some third-party JavaServer Faces Components
JSF Events (NI)
• Event notification and listener based on JavaBean 1.0.1
• Events are fired by each UI component
• Event handlers are registered with each component
• Three standard events– Value Change Event – generates by UIInput component– Action Event – generates by UICommand component– Phase Event – fire by JSF life cycle
• Custom events can easily be created and integrated into JSF
• If validation or conversion fails nothing happens– Action method bindings do not execute– Page just comes back– Most common JSF forum post – Use h:message or h:messages
• Example Hello User with required + six character validation
What is JSF?
• A framework which provides solutions for
– representing UI components – managing their state– handling events– input validation– Data binding – Automatic conversion – defining page navigation– supporting internationalization and accessibility.
JSF – Managed Bean-Intro
• Use to separate presentation from business logic
• Based on JavaBeans
• Use the declarative model
• Entry point into the model and event handlers
• Can have beans with various states
JSF – Value Binding (NI)
• Bind component value and attribute to model objects
• Behavior is configured in configuration file (faces-config.xml)
• You can do it visually in most tools
JSF Navigation - Example
<navigation-rule> <description>LOGIN PAGE NAVIGATION HANDLING</description> <from-view-id> /login.jsp </from-view-id> <navigation-case> <description>Handle case where login succeeded.</description> <display-name>Successful Login</display-name> <from-action>#{userBean.login}</from-action> <from-outcome>success</from-outcome> <to-view-id>/home.jsp</to-view-id> </navigation-case>
<navigation-case> <description>User registration for a new user succeeded.</description> <display-name>Successful New User Registration</display-name> <from-action>#{userBean.register}</from-action> <from-outcome>success</from-outcome> <to-view-id>/welcome.jsp</to-view-id> </navigation-case>
</navigation-rule>
• Example Here of two numbers
• EXAMPLE HERE
• After that “to pta yai chala”
JSF Component
UIComponent
ChildUIComponent
IdLocal Value
Attribute Map
EventHandling
Validatorshas
has
has
has
Render
has
Converters
has
Model
binds
JSF MVC Model
Model
Model
View
Renderer
Controller
Component Listener
JSF Application
JSF Framework
Application Logic
Model Objects
JSF Application
Servlet Container
DB
EJB Container
Client Devices
Phone
PDA
Laptop
JSF - HTML & CSS Integration
• HTML Integration– Pass-through attributes<h:inputText size=“5” onblur=“checkValue();” />
• HTML within JSF tags does not work without f:verbatim<h:panelGroup>
<f:verbatim>html</f:verbatim></h:panelGroup>
• Stylesheets Integration– Most HTML tags have one or more attributes (style, styleClass) for passing style
• Become a member of SDN (sun developer network)• http://java.sun.com/j2ee/javaserverfaces• http://forum.java.sun.com/forum.jsp?forum=427• http://www.jsfcentral.com• http://www.corejsf.com• http://www.theserverside.com• http://www.javaworld.com