Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.

Similar presentations


Presentation on theme: "CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren."— Presentation transcript:

1 CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren

2 Today’s Overview – Quick Review of HTTP and Servlets – JSF – (Part 2) Managed Beans Navigation Resource Bundles Common tags UIComponents CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

3 JSF – Managed Beans – Managed bean is a regular java bean managed by JSF framework – It is the “Model” of user interface component – JSF 1.2 : Registered using xml file, such as faces-config.xml – JSF 2.0 registered easily with @ManagedBean annotation – JSF 2.2 allows to be registered by CDI using @Named annotation CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

4 JSF – Managed Beans @ManagedBean annotation has two optional attributes : name : reference name of the bean. Default value: the name of the class eager : flag to specify if the application scoped bean will be initialized on startup or on first request Default value: false @ManagedBean(name=“Hello”, eager=true) CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

5 JSF – Managed Beans - Scopes – @RequestScoped : Bean lives as long as the HTTP request-response lives. (default) – @ViewScoped : Bean lives as long as user is interacting with the same JSF view – @SessionScoped : Bean lives as long as the HTTP session lives. – @ApplicationScoped : Bean lives as long as the web application lives. – @CustomScoped and@NoneScoped CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

6 JSF – Managed Property @ManagedProperty annotation is used to inject other managed beans or resources from JSF container. @ManagedBean public class HelloBean { @ManagedProperty(“#{otherBean}”) private OtherBean other; // need getters and setters etc… } CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

7 JSF – Page Navigation – Implicit Navigation : Navigate to pages from directly JSF pages or from managed beans – Conditional Navigation Rule: Define the navigation rules with faces-config.xml file. Form based rules If – else rules Redirect (and Forward) CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

8 JSF – Implicit Navigation OR public String gotoToPage2() { return "page2"; } CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

9 JSF – Conditional Navigation Rule hello.xhtml #{helloBean.doGreeting} success greeting.xhtml OR #{helloBean.somevalue eq 1} greeting.xhtml CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

10 JSF – Resource Bundles Resource bundles are used for text manipulation and Internationalization For better maintainability it is always recommended to put all text and messages into properties files. CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

11 JSF – Resource Bundles Define in faces-config.xml file as following: en tr resources.messages msg CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

12 JSF – Resource Bundles message_tr.properties text file : greeting = Merhaba greetuser = Merhaba {0} example.with.dot = nokta kullanımına örnek From xhtml page: xmlns:f="http://java.sun.com/jsf/core" CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

13 JSF – Resource Bundles Or from managed bean when needed: @ManagedProperty("#{msg}") private ResourceBundle bundle;... String greetmsg = bundle.getString(”greeting”); … CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

14 JSF – Common Tags Facelet Tags xmlns:ui="http://java.sun.com/jsf/facelets Used for templates: CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

15 JSF – Common Tags HTML Tags xmlns:h="http://java.sun.com/jsf/html Used for HTML output: CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

16 JSF – Common Tags Core Tags xmlns:f="http://java.sun.com/jsf/core Core JSF functionality: CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

17 JSF – Common Tag Attributes Id : identifier for a component binding: reference to component instance rendered: flag to set rendering styleClass: css class name value: value of the component converter: converter class name required: flag to set requirement CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

18 JSF – DHTML Event Attributes Allows to make JavaScript calls on specific events onblur: element loses focus onchange : element’s value changes onclick: mouse clicked over the element onfocus : element receives focus onkeypress: key is pressed onsubmit : form is submitted CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

19 JSF – Tag Examples - ui:composition dialog.xhtml: dialog.taglib.xml: http://cse446.yeditepe.edu.tr/sample dialog com/components/dialog.xhtml web.xml: javax.faces.FACELETS_LIBRARIES /WEB-INF/dialog.taglib.xml CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

20 JSF – Tag Examples - ui:composition page.xhtml: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ytu="http://cse446.yeditepe.edu.tr/sample"> Output: CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

21 JSF – UIComponent UIComponent is base class for all user interfaces components in JSF. UIComponent instances are organized into a component tree under a UIViewRoot Can be accessed from FacesContext instance CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

22 JSF – UIComponent UIComponent is base class for all user interfaces components in JSF. UIComponent instances are organized into a component tree under a UIViewRoot Can be accessed from FacesContext instance UIInput, UICommand, HtmlInputText, and many other… List componenets = FacesContext.getCurrentInstance().getViewRoot().getChildren(); CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş


Download ppt "CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren."

Similar presentations


Ads by Google