java ee - fhws 2014 - 3 jsf

Post on 26-Jun-2015

104 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Java EE - FHWS 2014 - 3 JSF

TRANSCRIPT

Java EEFull Stack for Business

Applications

Java Server Faces

2014-10-18

Referent: MATTHIAS REINING

Technical Manager Insurance at RGI Deutschland GmbH

blog: http://blog.matthias-reining.com

twitter: https://twitter.com/MatthiasReining

about.me: http://about.me/matthiasreining

2014-10-18

JAVA SERVER FACES

2014-10-18

DAS PROGRAMM

Die Spec Idee, Historie

Der App Server Containerkonzept Paketierung (JAR, WAR, EAR) Marktüberblick

Das Projekt Entwicklung eines Beispielprojektes IDE Settings, Oberflächen (Servlets, JSF),

Business Logic (EJB), Persistence (JPA), Java EE Patterns (CDI), Web Services (JAX-RS)

Die Produktion Buildmanagement (maven, Jenkins) Deployment einer Java EE Anwendung in

der Cloud bei einem PaaS Anbieter

2014-10-18

BESTANDSAUFNAHME

Welche Java UI Frameworks sind bekannt? Struts?

Wicket?

Vaadin?

GWT?

Spring Web MVC?

JSF?

2014-10-18

Wieso werden neben Servlets & JSPs noch andere Frameworks

genutzt?Komfortables Handling von Templates HTML Formulare Komponenten Wartung …

2014-10-18

JAVA SERVER FACES

2014-10-18

What is JSF?

JavaServer Faces (JSF) is a UI component based Java Web application framework. JSF is serverbased, e.g. the JSF UI components and their state are represented on the server with a defined life cycle of the UI components. JSF is part of the Java EE standard.

[Quelle: http://docs.oracle.com/javaee/7/firstcup/doc/java-ee001.htm#GKHOY]

2014-10-18

Java Server Faces

Tutorials / Nachschlagewerke

http://docs.oracle.com/javaee/7/tutorial/doc/jsf-intro.htm http://jsfatwork.irian.at/

2014-10-18

JSF - SpecReference Implementation: MojarraAlternative: MyFaces

Konkrete Implementierung hängt vom Application Server ab!

2014-10-18

MODEL – VIEW – CONTROLLER

Designpattern

2014-10-18

Java Server Faces

MODEL Java POJO

VIEW Faclet

CONTROLLER Managed Bean (Backing Bean)

2014-10-18

POJOModel

Plain Old Java Object

2014-10-18

FACLETSView

XHTML Files mit speziellen Tags <h:…>

2014-10-18

MANAGED BEAN

ControllerSynonym „Backing Bean“

@ManagedBean verutlich deprecated ab Java EE 8(http://

stackoverflow.com/questions/4347374/backing-beans-managedbean-or-cdi-beans-named

)

@Named (siehe später CDI)

2014-10-18

JSF Scopes

@RequestScope (javax.faces.bean.RequestScoped) @SessionScope (javax.faces.bean.SessionScoped) @ApplicationScope (javax.faces.bean.ApplicationScoped)

@ViewScope (javax.faces.bean.ViewScoped) @CustomScope (javax.faces.bean.CustomScoped) @NoneScope (javax.faces.bean.NoneScoped)

2014-10-18

UI KOMPONENTEN IN EINEM FACELETJSF-HTML-UI-Komponenten xmlns:h="http://xmlns.jcp.org/jsf/html

Tags zur grafischen Darstellung der Benutzeroberfläche

JSF-Core-UI-Komponentenxmlns:f="http://xmlns.jcp.org/jsf/core"

Tags, die unabhängig von der Darstellung sind. Beispielsweise gehören hierzu die Konvertierung und die Validierung der Geschäftsdaten oder auch die ActionListener.

JSF-Templating

xmlns:ui="http://xmlns.jcp.org/jsf/facelets"Tags für das Templating

[Quelle: Professionell entwickeln mit Java EE 7 – Das umfassende Handbuch, Seite 753]

2014-10-18

TEMPLATING MIT FACELETS

<ui:insert>„Platzhalter“ in einem Template

<ui:composition>Verbindung zum Template

<ui:define>„Implementierung“ eines Platzhalters

<ui:include>Wiederverwendung von „Snippets“

http://www.mkyong.com/jsf2/jsf-2-templating-with-facelets-example/http://www.oracle.com/technetwork/articles/java/facelets-454361.html

2014-10-18

JSF LIFECYCLE

1. RESTORE_VIEW2. APPLY_REQUEST_VALUES3. PROCESS_VALIDATIONS4. UPDATE_MODEL_VALUES5. INVOKE_APPLICATION6. RENDER_RESPONSE

2014-10-18

JSF Messages

FacesMessage m = new FacesMessage("läuft..");

FacesContext.getCurrentInstance().addMessage("testMessage", m);

<h:message for="testMessage„/>

Globale MessageFacesContext.getCurrentInstance().addMessage(null, m);

<h:messages/>

<h:messages globalOnly=„true“/>

2014-10-18

i18nInternationalization

2014-10-18

Validierung<f:validate…

2014-10-18

JSF Events & Listener

2014-10-18

JSF Komponenten Bibliotheken

Wichtig für GeschäftsanwendungenAllerdings nicht teil der Java EE Spezifikation

2014-10-18

JSF Komponenten Bibliotheken

Primefaces

Rich Faces

Ice Faces

My Faces

2014-10-18

http://primefaces.org/

2014-10-18

Aber…Wieso gibt es dann neben JSF noch andere Webframeworks?

2014-10-18

Stirbt JSF?

2014-10-18

top related