Your SlideShare is downloading. ×
0
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Jsf
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Jsf

1,588

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,588
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
32
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • The Restore View phase retrieves the component tree for the requested page if itwas displayed previously or constructs a new component tree if it is displayedfor the first time.
  • The JSF implementation initializes the JSF code and reads the index.xhtml page.That page contains tags, such as h:form and h:inputText. Each tag has an associatedtag handler class. When the page is read, the tag handlers are executed.The JSF tag handlers collaborate with each other to build a component treeThe component tree is a data structure that contains Java objects for all userinterface elements on the JSF page.Each component has a renderer that produces HTML output, reflecting the componentstate.
  • Yaratılmaları için default constructor
  • <context-param><param-name>javax.faces.CONFIG_FILES</param-name><param-value>WEB-INF/navigation.xml,WEB-INF/managedbeans.xml</param-value></context-param>
  • In most applications,the CDI conversation scope is a better choice than Custom Scopes
  • The none scope denotes a bean that is not kept in a scope map. Whenever anobject of the none scope is requested in a value expression, a new object is created.This can be useful for specifying beans that are set as properties of otherbeans.
  • If the initial term is not one of the predefined objects, the JSF implementationlooks for it in the request, view, session, and application scopes, in that order.In particular, all instantiated managed beans are located in these scope maps.If the search is still not successful, the JSF implementation attempts to constructa managed bean or a resource bundle with the given name.
  • The value of the action attribute is called the outcome.an outcome can be optionallymapped to a view ID.
  • <navigation-case><from-outcome>previous</from-outcome><if>#{quizBean.currentQuestion != 0}</if><to-view-id>/main.xhtml</to-view-id></navigation-case><to-view-id>#{quizBean.nextViewID}</to-view-id>
  • Transcript

    • 1. mustafa daşgın<br />mdasgin.blogspot.com<br />mustafa.dasgin@prime.com.tr<br />JSF<br />
    • 2. Servlets – 1997<br />Java EE’nin temeli<br />Şu an 3.0 (Java EE 6)<br />JavaServer Pages – 1999<br />Scriplets, EL, JSTL<br />JSF – 2004 (1.2 – 2006 / 2.0 - 2009)<br />Bileşen tabanlı<br />Öncelikle..<br />
    • 3. Java EE için standart web çatısı (MVC)<br />Bileşen tabanlı (Tekrar kullanılabilir arayüz bileşenleri)<br />İstemci tarafından üretilen “Event”ler<br />Navigation, Renderers, Validators, Converters<br />Üçüncü parti bileşen yazabilme imkanı<br />JSF’e Giriş<br />
    • 4. Restore View<br />Apply Request Values<br />Process Validation<br />Update Model Values<br />Invoke Application<br />Render Response<br />JSF Yaşam Döngüsü<br />
    • 5. Restore View - Tag Handler<br />Sayfa ilk kez yükleniyorsa bileşen ağacı oluşturulur.<br />Bileşen ağacı bileşen nesnelerinin tutulduğu veri yapısı.<br />
    • 6. Managed Beans (Backing Beans)<br />Framework tarafından yaratılabilen ve yönetilebilen Java nesneleri<br />İş mantığı için başlangıç noktası<br />Temel Bağımlılık Aktarımı<br />@ManagedProperty(value="#{userService}")(JSF 2.0)<br />#{user.name} -> “user” bean’in getName metotu<br />
    • 7. XML veya notlandırma (annotation)<br /><managed-bean><br /><managed-bean-name>user</managed-bean-name><br /><managed-bean-class>com.prime.training.UserBean</managed-bean-class><br /><managed-bean-scope>request</managed-bean-scope><br /></managed-bean><br />@ManagedBean(name=“user”)<br />CDI beans (JEE 6 uyumlu Uygulama Sunucularında)<br />@Named(“user”)<br />Managed Beans Tanımlama<br />
    • 8. JSF ve CDI ortak<br />@RequestScoped<br />@SessionScoped<br />@ApplicationScoped<br />Sadece JSF2.0<br />@ViewScoped<br />@CustomScoped("#{expr}")<br />Sadece CDI<br />@ConversationScoped<br />Bean Scopeları<br />
    • 9. Bağımlılık Aktarımında Scope Kısıtı<br />
    • 10. @PostConstruct<br />@PreDestroy<br />Bean Yaşam Döngüsü Metotları<br />@ManagedBean<br />@SessionScoped<br />public class MyBean {<br />@PostConstruct<br />public void initialize() {<br />// initialization code<br />}<br />@PreDestroy<br />public void shutdown() {<br />// shutdown code<br />}<br />// other bean methods<br />}<br />
    • 11. Bean niteliklerine ve metotlarına erişimi sağlar.<br /><h:inputText value="#{user.name}"/><br />Expression Language (EL)<br />
    • 12. JSF Tarafından Kullanılan EL Değişkenleri<br />
    • 13. #{itemService.price(“book")}-> double price(String)<br /><h:commandButton value="Previous" action="#{formBean.move(-1)}"/><br />Aşırı yüklenen (overloading) metotlar desteklenmez.<br />EL – Metot Çağırımı (JSF 2.0)<br />
    • 14. Durağan (Static)<br /><h:commandButton label="Login" action="welcome"/><br />Devingen (Dynamic)<br /><h:commandButton label="Login" action="#{loginController.verifyUser}"/><br />Sayfa Yönlendirme<br />
    • 15. Sayfa Yönlendirme – View IDs<br /><navigation-rule><br /><from-view-id>/index.xhtml</from-view-id><br /><navigation-case><br /><from-outcome>success</from-outcome><br /><to-view-id>/welcome.xhtml</to-view-id><br /></navigation-case><br /><navigation-case><br /><from-outcome>failure</from-outcome><br /><to-view-id>/newuser.xhtml</to-view-id><br /></navigation-case><br /></navigation-rule><br />
    • 16. Standart JSF Tagleri<br />
    • 17. JSF Core Tags<br /><h:outputFormat value="#{msgs.currentScore}"><br /><f:param value="#{quizBean.score}"/><br /></h:outputFormat><br />
    • 18. JSF HTML Tags<br />
    • 19. JSP ileyaşanan sorunları çözmek için geliştirilmiştir.<br />JSF 2.0 ile varsayılan önyüz teknolojisi oldu.<br />Templating<br />Facelets<br />
    • 20. Facelets Tags<br />xmlns:ui="http://java.sun.com/jsf/facelets<br />
    • 21. Tag işlevi XHTML sayfası olarak hazırlanır.<br />Facelets – Custom Tags<br /><ui:composition><br /><c:if test="#{type != 'password'}"><br /><h:inputText id="#{id}" value="#{inputValue}"/><br /></c:if><br /><c:if test="#{type == 'password'}"><br /><h:inputSecret id="#{id}" value="#{inputValue}"/><br /></c:if><br /></ui:composition><br />
    • 22. Tag kütüphanesi dosyasında tanımı yapılır.<br />Tag kütüphanesi için namespace tanımı<br />Her tag için isim<br />Her tag için kaynak<br />Facelets – Custom Tags (Devam)<br /><facelet-taglib><br /><namespace>http://dasgin/facelet/customtag</namespace><br /><tag><br /><tag-name>customInput</tag-name><br /><source>tags/customInput.xhtml</source><br /></tag><br /></facelet-taglib><br />
    • 23. web.xml tanımı<br />Facelets – Custom Tags (Devam)<br /><context-param><br /><param-name>facelets.LIBRARIES</param-name><br /><param-value>/WEB-INF/mycustom.taglib.xml</param-value><br /></context-param><br />
    • 24. İstemciden gönderilen her şey String<br />String’ten Java tiplerine dönüşüm<br />Öntanımlı & Geliştirici tanımlı Converters<br />Converters<br /><h:inputText value="#{payment.date}"><br /><f:convertDateTime pattern="MM/yyyy"/><br /></h:inputText><br /><h:outputText value="#{payment.amount}"><br /><f:convertNumber type="currency"/><br /></h:outputText><br />
    • 25. “Process Validation” safhasında kontrol<br />Öntanımlı & Geliştirici tanımlı Validators<br />String boyu kontrolü<br />Sayısal değerlerin limit kontrolü (ör: > 0 ve <=100)<br />Reqular Expression ile kontrol<br />Değer girilmiş mi kontrolü<br />Validators<br /><h:inputText id="amount" value="#{payment.amount}"><br /><f:validateLongRange minimum="10" maximum="10000"/><br /></h:inputText><br /><h:inputText id="date" value="#{payment.date}"><br /><f:validateRequired/><br /></h:inputText><br /><h:inputText id="date" value="#{payment.date}”required="true"/><br />
    • 26. @Null, @NotNull<br />@Min, @Max<br />@DecimalMin, @DecimalMax<br />@Digits<br />@AssertTrue, @AssertFalse<br />@Past, @Future<br />@Size<br />@Pattern<br />Bean Validation – JSR 303<br />
    • 27. Hata Mesajları<br /><h:inputText id="amount" label="#{msgs.amount}" value="#{payment.amount}"/><br /><h:message for="amount"/><br />
    • 28. JSF 2.0 ile standart Ajax API<br />Sayfanın bir bölümünü işleme ve güncelleme<br />Ajax<br />
    • 29. @this (varsayılan)<br />@form<br />@all<br />@none<br />Ajax - Keywords<br /><h:inputText id="name" value="#{user.name}"><br /><f:ajax event="keyup" execute="@thissurname" render="echo"/><br /></h:inputText><br />...<br /><h:outputText id="echo" value="#{user.screenName}"/><br />
    • 30. CoreJavaServerFaces3rdEdition (PrenticeHall)<br />Kaynak<br />

    ×