JSF (Java Server Faces) Melih Sakarya www.melihsakarya.com melih.sakarya@gmail.com



Similar documents
JSF Melih Sakarya. Java Server Faces PrimeFaces

Getting Started Guide. Version 1.8

Securing JSF Applications Against the OWASP Top Ten. The OWASP Foundation JSF One Rich Web Experience Sep 2008

JavaServer Faces 2.0: The Complete Reference

JBoss Seam Next Generation Integration Framework.

PRIMEFACES MOBILE USER S GUIDE

CC68J APLICACIONES EMPRESARIALES CON JEE JSF. Profesores: Andrés Farías

Getting Started Guide. Version: 4.0.0

Managed Beans II Advanced Features

Recommended JSF Enhancements

Java EE 6 Development with NetBeans 7

Master s Thesis. Generating Web Applications with Abstract Pageflow Models

Developer s Guide. Version 1.8

Web Development in Java Live Demonstrations (Live demonstrations done using Eclipse for Java EE 4.3 and WildFly 8)

Web Anwendungen Entwickeln mit JSF, Spring und Tomcat

White Paper. JavaServer Faces, Graphical Components from Theory to Practice

HOW DO I... Topics in This Chapter

<Insert Picture Here> Oracle Mobile Enterprise Application Platform Overview

<Insert Picture Here> Betting Big on JavaServer Faces: Components, Tools, and Tricks

The Oracle Fusion Development Platform

Enterprise Java Web Application Frameworks & Sample Stack Implementation

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

JavaServer Faces 2.0. Bernd Bohmann. Matthias Weßendorf. Agenda. Agenda. IRIAN Deutschland Apache MyFaces Tobago CORE. Mehr als nur ein Web-Framework

ADF. Joe Huang Joe Huang Senior Principal Product Manager, Mobile Development Platform, Oracle Application Development Tools

JavaServer Faces: The Complete Reference

Defeating XSS and XSRF with JSF Frameworks

An introduction to creating JSF applications in Rational Application Developer Version 8.0

The Java EE 7 Tutorial Volume 1. Fifth Edition

Dissecting Java Server Faces for Penetration Testing

CrownPeak Java Web Hosting. Version 0.20

4! Technology Evolution! for Web Applications

URL-rewriting, dynamic parameters, bookmarks, and navigation for Servlet, Java EE, and JSF

Spring Web Flow Reference Guide

Aspects of using Hibernate with CaptainCasa Enterprise Client

SSC - Web development Model-View-Controller for Java web application development

ASP.NET(C#) ile Kayıt Listeleme, Silme ve Düzenleme İşlemi

Client Side Binding of Dynamic Drop Downs

T-4 - Develop Better Java EE Applications With Eclipse Web Tools Platform. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Oracle Application Development Framework Overview

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

Certified PHP/MySQL Web Developer Course

Java EE 6 development with Eclipse, Netbeans, IntelliJ and GlassFish. Ludovic Champenois Oracle Corporation

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

DIPLOMA IN WEBDEVELOPMENT

<Insert Picture Here> Building a Complex Web Application Using ADF and Siebel

A Comparison of Open Source Application Development Frameworks for the Enterprise

Portals, Portlets & Liferay Platform

Tutorial on Building a web Application with Jdeveloper using EJB, JPA and Java Server Faces By Phaninder Surapaneni

ADF Code Corner. 92. Caching ADF Web Service results for in-memory filtering. Abstract: twitter.com/adfcodecorner

4 Technology Evolution for Web Applications

Building Web Services with Apache Axis2

Controlling Web Application Behavior

IBM WebSphere Server Administration

Java (J2SE & J2EE) and Web Development Training Catalog

<Insert Picture Here> Web 2.0 Data Visualization with JSF. Juan Camilo Ruiz Senior Product Manager Oracle Development Tools

Web and Enterprise Applications Developer Track

Evaluating Presentation Layer Development Frameworks for EJB Applications in J2EE Architecture

Complete Java Web Development

Developing XML Solutions with JavaServer Pages Technology

Net-WMS FP Net-WMS SPECIFIC TARGETED RESEARCH OR INNOVATION PROJECT. Networked Businesses. D.8.1 Networked architecture J2EE compliant

Experiences with Open-Source BPM/SOA-based Stack using Java EE Rok Povše, Matjaž B. Jurič

maximizing IT productivity

Supporting Multi-tenancy Applications with Java EE

How To Develop A Mobile Application On An Android Device

WebSphere Server Administration Course

How To Write A Web Framework In Java

<Insert Picture Here> Java EE 7: the New Cloud Platform

MVC FRAMEWORK MOCK TEST MVC FRAMEWORK MOCK TEST II

How To Write An Ria Application

JSP Java Server Pages

JAVA PROGRAMMING PATTERN FOR THE PREFERENCES USABILITY MECHANISM

Ruby On Rails. CSCI 5449 Submitted by: Bhaskar Vaish

CQCON 2013: five Sling features you should know

Building an Agile PLM Web Application with JDeveloper and Agile 93 Web Services

Master Thesis. Arnold Kemoli. Design and Implementation of a Dynamic Component based Web Application Framework

Framework Adoption for Java Enterprise Application Development

Rapid Application Development. and Application Generation Tools. Walter Knesel

Oracle JDeveloper 10g for Forms & PL/SQL

TTIWResponsiveList - TTIWDBResponsiveList

The end. Carl Nettelblad

Building and Using Web Services With JDeveloper 11g

BT Operasyonlarının Yeniden Tanımlanması Otomasyon ve Orkestrasyon Zafer SALTIK, Kıdemli Çözümler Danışmanı

IBM Script Portlet for WebSphere Portal Release 1.1

BEST WEB PROGRAMMING LANGUAGES TO LEARN ON YOUR OWN TIME

Client-server 3-tier N-tier

applications. JBoss Enterprise Application Platform

White Paper On. Single Page Application. Presented by: Yatin Patel

design coding monitoring deployment Java Web Framework for the Efficient Development of Enterprise Web Applications

Wicket Hiroto Yamakawa

Ehcache Web Cache User Guide. Version 2.9

<Insert Picture Here> Java EE 7: the New Cloud Platform

How to make a good Software Requirement Specification(SRS)

Transcription:

JSF (Java Server Faces) Melih Sakarya www.melihsakarya.com melih.sakarya@gmail.com

JSF Nedir? MVC (Model-View-Controller) JSR Standartı (JSR-127, JSR 252) Component Oriented Event Driven Farklı JSF implementasyonları 3. parti JSF bileşenleri (Ice Faces, Rich Faces, Woodstock)

JSF in ortaya çıkışı 2001 ortalari Amy Fowler 2002 yilinda Ed Burns Craig McClanahan

JSF Gelişimi JSF 2.0... JSF 1.2 (11 may 2006) JSF 1.1 (27 may 2004) JSF 1.0 (11 mar 2004)

Specification JSR127 JSF 1.1 JSR252 JSF 1.2

Gerçeklemeler (Implementation) MyFaces (Apache) Sun RI (Reference Implementation)...

Neden JSF Standart olması RAD desteği Bileşen mimarisinin kolaylığı Farklı grupların bileşen desteği Gelişmiş EL (Expression Language desteği)

JSF Yaklaşımı Bileşen yönelimli Olay(event) tabanli Bileşenlere olay(event) tanımlama Bileşenleri Java objelerine erişim (EL desteği ile)

LifeCycle Fazları

JSF Bileşenleri core Validation, conversion, event handling... html 18 standart core tag presentation (sunum) 25 standart html tag

html bileşenleri <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

html bileşenleri... h:inputtext h:outputtext h:commandbutton h:datatable h:column

core bileşenler <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

core bileşenler f:view f:convertdatetime f:selectitem f:validatelength...

Bileşenlerin render edilmesi <h:inputtext id="name" value= aaa /> <input type ="text" id="name" value="aaa" />

Basit bir JSF sayfası <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <html> <head> <title></title> </head> <body> <f:view> <h:outputtext value="deneme" /> </f:view> </body> </html>

EL (Expression Language) #{managedbeanadi.attribuate

Basit bir JSF sayfası <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <html> <head> <title></title> </head> <body> <f:view> <h:outputtext value= #{ornek.deneme" /> </f:view> </body> </html>

Managed Bean Basit Java sınıflarıdır. Herhangi bir sınıfı miras almasına gerek yoktur. JSF tarafında otomatik oluşturulurlar. JSF context i içerisinden erişilebilirler faces-config.xml içerisinde tanımlanmalıdırlar

Managed Bean JSF Manage Bean Scope Session Application Request EL (Expression Language) ile erişilebilirler.

Örnek Managed Bean package com.vardar.seminer; public class Ornek { private String ad; public String getad() { return ad; public void setad(string ad) { this.ad = ad;

faces-config.xml tanımı <managed-bean> <managed-bean-name>ornek</managed-bean-name> <managed-bean-class> com.vardar.seminer.ornek </managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>

Örnek JSF Form <f:view> <h:form id="kayitformu"> <h:inputtext value="#{ornek.ad" /> <h:commandbutton action="#{ornek.kayit" value="kayit" /> </h:form> </f:view>

Örnek JSF Form package com.vardar.seminer; public class Ornek { public Ornek(){ this.ad="melih"; private String ad; public String getad() { return ad; public void setad(string ad) { this.ad = ad; public void kayit(){ System.out.println(ad + " adina kayit basarili olarak yapildi");

h:selectonemenu <h:selectonemenu value="#{ornek.cinsiyet" > <f:selectitem itemlabel="bay" itemvalue="bay"/> <f:selectitem itemlabel="bayan" itemvalue="bayan"/> </h:selectonemenu>

SelectItems SelectItem s1 = new SelectItem("34","İstanbul"); SelectItem s2 = new SelectItem("35","İzmir"); SelectItem s3 = new SelectItem("06","Ankara"); sehirler.add(s1); sehirler.add(s2); sehirler.add(s3);

ValueChangeListener <h:selectonemenu value="" valuechangelistener="#{test.processvaluechange" onchange="this.form.submit()"> <f:selectitem itemvalue="1" itemlabel="a"/> <f:selectitem itemvalue="2" itemlabel="b"/> <f:selectitem itemvalue="3" itemlabel="c"/> </h:selectonemenu>

ValueChangeEvent import javax.faces.event.abortprocessingexception; import javax.faces.event.valuechangeevent; public class Test { private String deger; public String getdeger() { return deger; public void setdeger(string deger) { this.deger = deger; public void processvaluechange(valuechangeevent event) { System.out.println("event.getNewValue() = " + event.getnewvalue());

SelectItems <h:selectonemenu> <f:selectitems value="#{test.list"/> </h:selectonemenu>

SelectItems public class Test { public Test(){ SelectItem s1 = new SelectItem("1","A"); SelectItem s2 = new SelectItem("2","B"); SelectItem s3 = new SelectItem("3","C"); list.add(s1); list.add(s2); list.add(s3); List<SelectItem> list = new ArrayList<SelectItem>(); public List<SelectItem> getlist() { return list; public void setlist(list<selectitem> list) { this.list = list;

PanelGrid <h:panelgrid columns="3"> <h:outputlabel for= kullaniciadi" value= Kullanıcı Adı"/> <h:inputtext id=" kullaniciadi" value="#{kullanicibean.rumuz"/> <h:message for=" kullaniciadi"></h:message> <h:outputlabel for="sifre" value= Sifre"/> <h:inputsecret id="sifre" value="#{kullanicibean.sifre"/> <h:message for="sifre"></h:message> </h:panelgrid> <h:commandbutton value= Giris" action="#{kullanicibean.sistemegir"/>

DataTable <h:datatable value="#{table.kullaniciliste" var="kullanici"> <h:column> <h:outputtext value="#{kullanici.ad"/> </h:column> <h:column> <h:outputtext value="#{kullanici.soyad"/> </h:column> </h:datatable>

DataTable value binding public class Table { public Table(){ kullaniciliste.add(new KullaniciPojo("Melih","Sakarya",27)); kullaniciliste.add(new KullaniciPojo("Umit","Vardar",38)); kullaniciliste.add(new KullaniciPojo("Pinar","Cayirlioglu",24)); List<KullaniciPojo> kullaniciliste = new ArrayList<KullaniciPojo>(); public List<KullaniciPojo> getkullaniciliste() { return kullaniciliste; public void setkullaniciliste(list<kullanicipojo> kullaniciliste) { this.kullaniciliste = kullaniciliste;

DataTable pojo public class KullaniciPojo { public KullaniciPojo(){ public KullaniciPojo(String ad, String soyad, Integer yas){ this.ad = ad; this.soyad = soyad; this.yas = yas; String ad; String soyad; Integer yas; public String getad() { return ad; public void setad(string ad) { this.ad = ad; public String getsoyad() { return soyad; public void setsoyad(string soyad) { this.soyad = soyad; public Integer getyas() { return yas; public void setyas(integer yas) { this.yas = yas;

Navigation <navigation-rule> <from-view-id>/test.jsp</from-view-id> <navigation-case> <from-outcome>dogru</from-outcome> <to-view-id>/basarili.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>yanlis</from-outcome> <to-view-id>/hata.jsp</to-view-id> </navigation-case> </navigation-rule>

Örnek kullanıcı giriş uygulaması <h:inputtext value="#{ornek.kullaniciadi" /><br> <h:inputsecret value="#{ornek.sifre" /><br> <h:commandbutton action="#{ornek.giris" value= Giriş Yap" />

Örnek kullanıcı giriş uygulaması public String giris(){ if(kullaniciadi.equals( vardar") && sifre.equals("123456")){ return "dogru"; else{ return "yanlis";

Validation <f:validatelength minimum= 5 maximum= 15 /> <f:validatelongrange minimum= 2 maximum= 18 /> <f:validatedoublerange minimum= 2.4 maximum= 7.18 />

Converter <h:outputtext value="#{table.tarih" > <f:convertdatetime pattern="dd/mm/yyyy"/> </h:outputtext><br/> <h:outputtext value="#{table.tarih" > <f:convertdatetime pattern="dd.mm.yyyy"/> </h:outputtext><br/> <h:outputtext value="#{table.tarih" > <f:convertdatetime pattern="yyyy"/> </h:outputtext><br/>

3. parti JSF bileşenleri RichFaces MyFaces IceFaces ADF Faces Woodstock

RichFaces 3. party JSF component Ajax desteği A4JSF kütüphanesi Zengin bileşen seçenekleri JQuery desteği

RichFaces kurulumu richfaces-api.jar richfaces-impl-3.2.1.jar richfaces-ui-3.2.1.jar

RichFaces kurulumu <context-param> <param-name>org.richfaces.skin</param-name> <param-value>bluesky</param-value> </context-param> <filter> <display-name>richfaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.filter</filter-class> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>faces Servlet</servlet-name> <dispatcher>request</dispatcher> <dispatcher>forward</dispatcher> <dispatcher>include</dispatcher> </filter-mapping>

RichFaces kullanımı <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

A4J (Ajax for JSF) <h:selectonemenu value="#{test.deger"> <f:selectitem itemvalue="1" itemlabel="a"/> <f:selectitem itemvalue="2" itemlabel="b"/> <f:selectitem itemvalue="3" itemlabel="c"/> <a4j:support event="onchange" rerender="degeralani"/> </h:selectonemenu><br/> <a4j:outputpanel id="degeralani"> deger = <h:outputtext value="#{test.deger" id="d"/> </a4j:outputpanel>

A4J <a4j:commandbutton /> <a4j:form> </a4j:form>

a4j:form <a4j:form> <h:inputtext value="#{demo.ad" /><br/> <h:inputtext value="#{demo.soyad" /><br/> <h:commandbutton action="#{demo.kayit" value="kayit" /> <a4j:commandbutton action="#{demo.kayit" value="ajax Kayit"/> </a4j:form><br/><br/> <h:inputtext value="#{demo.ad" />

a4j:form public class Demo { private String ad; private String soyad; public String getad() { return ad; public void setad(string ad) { this.ad = ad; public String getsoyad() { return soyad; public void setsoyad(string soyad) { this.soyad = soyad; public void kayit(){ System.out.println("kayit yapildi...");

Ajax pooling <h:form> <a4j:poll id="poll" interval="500" rerender="poll,test" /> </h:form> <h:outputtext value="#{demo.tarih" id="test"/>

Ajax pooling import java.util.date; public class Demo { private Date tarih; public Date gettarih() { tarih = new Date(); return tarih; public void settarih(date tarih) { this.tarih = tarih;

RichFaces componentleri <rich:calendar /> <rich:calendar popup="false"/> <rich:datatable> <rich:gmap> <rich:suggestionbox height="" width="">

RichFaces demo http://livedemo.exadel.com/richfaces-demo

Son