Java server faces
This presentation is the property of its rightful owner.
Sponsored Links
1 / 28

Java Server Faces PowerPoint PPT Presentation


  • 86 Views
  • Uploaded on
  • Presentation posted in: General

Java Server Faces. Çağatay Çivici Apache MyFaces Team Member [email protected] Çağatay Çivici. Apache MyFaces Project Committer OpenLogic Expert Group Member Sourceforge jsf-comp project developer JSF Client Side Validators Acegi Security Framework’s JSF Components

Download Presentation

Java Server Faces

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Java server faces

Java Server Faces

Çağatay Çivici

Apache MyFaces Team Member

[email protected]


A atay ivici

Çağatay Çivici

  • Apache MyFaces Project Committer

  • OpenLogic Expert Group Member

  • Sourceforge jsf-comp project developer

  • JSF Client Side Validators

  • Acegi Security Framework’s JSF Components

  • JFreeChart for JSF : JSF Chart Creator

  • FacesTrace: Visual Debugger of JSF


Agenda

Agenda

  • What is JSF?

  • JSF Component Model and Binding mechanism

  • JSF Request Lifecycle

  • IOC and Managed Beans

  • Navigations

  • Internalization and Resource Bundles

  • Extending JSF

  • Integration with Other Frameworks (Spring Framework Example)

  • Ajax with JSF

  • Facelets

  • Apache MyFaces

  • IDE Support

  • Future of JSF

  • Questions


What is jsf

What is JSF?

  • a component oriented and event driven web framework to build up web applications.

  • a Standard

  • various implementations

    • Sun Reference Implementation

    • Apache MyFaces

    • Oracle ADF

    • IBM


Architecture

Architecture


Similar concepts

Similar Concepts

  • Asp.net

  • Tapestry

  • Wicket

  • Swing


Jsf vs struts

JSF vs Struts

  • Struts is an action framework

    • Controller of the MVC pattern

  • JSF is an event driven and component oriented framework.

    • JSF contains all the members of the MVC.

      • Model : Managed Beans

      • View : Components

      • Controller : Faces Servlet


Jsf component model

JSF Component Model

  • Covers a wide range components.

    • Reusable

    • Customizable

    • State aware

  • Easy to plug in third party components.

  • Easy to create custom components of your own.

  • Renderers brings abstraction


Simple example htmlinputtext

Simple Example: HtmlInputText

  • Declared as;

    • <h:inputText id=“id1” value=“xxx” />

  • Gives the output

    • <input type=“text” id=“parentformid:id1” value=“xxx” />

  • Customization attributes like;

    • Styleclass

    • Javascript events (onmousover etc...)


Binding makes jsf powerful

Binding makes JSF powerful

  • Value binding; binds a bean’s variable to a component.

    • <h:inputText value=“#{person.name}” />

  • Action binding, binds a method to an action component.

    • <h:commandButton action=“{personSavePage.savePerson}” />


Jsf component tree

JSF Component Tree

  • Components are represented using a tree.

  • <f:view>

    <h:form id=“form1”>

    <h:outputText id=“lbl_name” value=“Name”>

    <h:inputText id=“txt_name” value=“NameValue”>

    </h:form>

    </f:view>


Event handling

Event Handling

  • Events are created based on the request parameters.

  • Each event is broadcasted to the related listeners.


State management

State Management

  • JSF saves and restores the state of the components in each faces request.

    • Client

      • As a hidden variable

    • Server

      • As a session entry


Jsf request lifecycle

JSF Request LifeCycle


Conversion and validation

Conversion and Validation

  • Submitted form values are strings

  • Conversion takes place to convert these values to java objects

  • Validation mechanism validates these converted objects

    • Built-in converters and validators

    • Easy to write custom converters and validators


Case study

Case Study


Ioc and managed beans

IOC and Managed Beans

  • JSF uses it’s own container to manage the beans in it’s context.

  • <managed-bean>

    <managed-bean-name>pc_Index</managed-bean-name>

    <managed-bean-class>demo.Index</managed-bean-class>

    <managed-bean-scope>request</managed-bean-scope>

    <managed-property>

    <property-name>someVariable</property-name>

    <value>#{pc_DB}</value>

    </managed-property>

    </managed-bean>

    <managed-bean>

    <managed-bean-name>pc_DB</managed-bean-name>

    <managed-bean-class>demo.Db</managed-bean-class>

    <managed-bean-scope>session</managed-bean-scope>

    </managed-bean>


Navigations

Navigations

  • <navigation-rule>

    <from-view-id>/login.jsp</from-view-id>

    <navigation-case>

    <from-outcome>success</from-outcome>

    <to-view-id>/mainmenu.jsp</to-view-id>

    </navigation-case>

    <navigation-case>

    <from-outcome>failure</from-outcome>

    <to-view-id>/login.jsp</to-view-id>

    </navigation-case>

    </navigation-rule>

  • Action specific

    • <from-action>#{loginBean.loginAction}</from-action>

  • Supports patterns

    • <from-view-id>*</from-view-id>


Extending jsf

Extending JSF

  • Navigation Handler

  • View Handler

  • Custom Resolvers

  • Phaselisteners

  • Custom Components


Multilanguage

Multilanguage

  • Support for resource bundles

    • <application><locale-config><default-locale>tr</default-locale><supported-locale>en</supported-locale><supported-locale>en_US</supported-locale><supported-locale>de</supported-locale></locale-config><message-bundle>jsfsunum.messages

      </message-bundle>

      </application>

  • jsfsunum/messages.tr

    • msg_welcome = Merhaba

  • Bundles on faces pages

    • <f:loadBundle basename=“jsfsunum.labels" var="msg"/>


Integration with spring

Integration with Spring

  • JSF-Spring

    • Using a delegating variable resolver

  • <application><variable-resolver>

    org.springframework.web.jsf.DelegatingVariableResolver

    </variable-resolver>;

    </application>

    <managed-bean>  <managed-bean-name>backingBeanName</managed-bean-name>  <managed-bean-class>

       yourpackagename.backingBeanClass

    </managed-bean-class>  <managed-bean-scope>request</managed-bean-scope>

     <managed-property>   <property-name>facadeService</property-name>  <property-class>    packagename.FacadeService  </property-class>   <value>#{facadeService}</value>  </managed-property>

    </managed-bean>


Ajax with jsf

Ajax with JSF

  • Components with ajax support

  • JSF ajax frameworks

    • JSF Avatar

    • Ajax Anywhere

    • Ajax4jsf

    • IceFaces

    • Ajax enabled myFaces components


Facelets

Facelets

  • Replacing jsp markup with xhtml

  • Templating

  • Composite components

  • Powerful view handler than jsf 1.1

  • No need for tag handlers of jsp


Jsf ide support

JSF IDE Support

  • Exadel Studio

  • IBM RSA

  • Oracle JDeveloper

  • Sun Studio Creator

  • MyEclipse

  • Bea Workshop

  • Macromedia jsftoolbox

  • Netbeans


Introducing apache myfaces

Introducing Apache MyFaces

  • Open source implementation of JSF

  • Contains extended tomahawk library

  • Oracle ADF donation


Myfaces component demo

MyFaces Component Demo

  • Basic form components

  • Datatable

  • File upload

  • Date and Calendar

  • Jscookmenu

  • Schedule

  • Accordion panel

  • Tabbed Panel

  • Ajax components

  • Tree

  • Dojo Toolkit

  • Fisheye

  • Html Editor

  • Chart Creator (jsf-comp component)


Future

Future

  • JSF 1.2 and later JSF 2.0

  • More powerful IDE support

  • More components

  • Integrated Ajax Support


The end questions

The End - Questions?

  • [email protected]

  • www.jroller.com/page/cagataycivici


  • Login