Facelets Mimi Opkins CECS493 Fall 2016. Facelets  User interfaces are typically a web application’s most volatile aspect during development, and they.

Slides:



Advertisements
Similar presentations
EIONET Training Zope Page Templates Miruna Bădescu Finsiel Romania Copenhagen, 28 October 2003.
Advertisements

Chapter 3 – Web Design Tables & Page Layout
Cascading Style Sheets
Cascading Style Sheets
1 XSLT – eXtensible Stylesheet Language Transformations Modified Slides from Dr. Sagiv.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
XHTML1 Tables and Lists. XHTML2 Objectives In this chapter, you will: Create basic tables Structure tables Format tables Create lists.
JavaServer Faces Dr Jim Briggs 1JavaServer Faces.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
Course Textbook: Build Your Own ASP.Net Website: Chapter 2
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
® IBM Software Group © 2006 IBM Corporation Creating JSF/EGL Template Pages This section describes how to create.JTPL (Java Template Pages) using the Page.
Cascading Style Sheet. What is CSS? CSS stands for Cascading Style Sheets. CSS are a series of instruction that specify how markup elements should appear.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
Ch6:creating consistent looking web sites. Master pages Master page defines a combination of fixed content and content place holder to hold the web page(.aspx)
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Eat Your Words! Creating webpage Layout. CONTENT The Layout of a Webpage HEADER FOOTER Each of these sections represents a ‘div’ (or divider). By linking.
NetTech Solutions Working with Web Elements Lesson 6.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
CSCI 6962: Server-side Design and Programming Java Server Faces Components and Tags.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Dreamweaver MX. 2 Overview of Templates n Templates represent a web page design or _______ that will be common to multiple pages. n There are two situations.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 41 JavaServer Face.
Chapter 5 Creating Page Templates. Principles of Web Design 2nd Ed. Chapter 5 2 Principles of Web Design Chapter 5 Objectives Understand table basics.
Web Design Part I. Click Menu Site to create a new site root.
1 © Netskills Quality Internet Training, University of Newcastle Using Style Sheets in Dreamweaver CS © Netskills, Quality Internet Training, University.
Cascading Style Sheets CSS. Source W3Schools
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
CSCI 6962: Server-side Design and Programming Facelets and User Interface Design.
Looking at various Rich Message options in KRAD Kuali University: Apply Now Lab : Rich Messages Lab Objectives Understand what Rich Messages are and how.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Positioning Objects with CSS and Tables
HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML.
Standard JSF Tags Mimi Opkins CECS 493 Fall 2016.
HTML Basics Text, Images, Tables, Forms. HTML Structure HTML is comprised of “elements” and “tags” – Begins with and ends with Elements (tags) are nested.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
Section 10.1 Define scripting
Advanced HTML Tags:.
Module 1 Introduction to JavaScript
Getting Started with CSS
Bare boned notes.
Organizing Content with Lists and Tables
Working with Tables: Module A: Table Basics
Facelets BY: Tejashri Udavant..
Intro to Dreamweaver Web Design Section 8-1
Bare bones notes.
W3C Web standards and Recommendations
ASP.NET Web Controls.
Section 17.1 Section 17.2 Add an audio file using HTML
Arrays and files BIS1523 – Lecture 15.
Introduction to XHTML.
IS-907 Java EE Templating.
Section 10.1 YOU WILL LEARN TO… Define scripting
Website Design 3
Ruby on Rails by Manik Juneja
Ruby on Rails by Manik Juneja
Tutorial 6 Creating Dynamic Pages
In Class Programming BIS1523 – Lecture 11.
Introduction to Web Authoring
Bare bones notes.
Web Development Using ASP .NET
Using Templates and Library Items
Exercise 24 – Software Skills
5.00 Apply procedures to organize content by using Dreamweaver. (22%)
EXTENDING COMPONENTS AND TABLE TRANSFORMATIONS WITH XSL
HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML
Presentation transcript:

Facelets Mimi Opkins CECS493 Fall 2016

Facelets  User interfaces are typically a web application’s most volatile aspect during development, and they are often comprised of brittle code that is difficult to change, making user interfaces expensive to develop.  You can implement flexible UIs with Facelets.

Facelets Tags  Facelets supports a number of tags for templating and other purposes.  Facelets tags can be grouped in these categories:  Including content from other XHTML pages ( ui:include )  Building pages from templates ( ui:composition, ui:decorate, ui:insert, ui:define, ui:param )  Creating custom components without writing Java code ( ui:component, ui:fragment )  Miscellaneous utilities ( ui:debug, ui:remove, ui:repeat )  To use Facelets tags, add the following namespace declaration to your JSF page: xmlns:ui="

Facelets Tags

Templating with Facelets  Most web applications follow a similar pattern, in which all pages have a common layout and styling. For example, it is typical for pages to have the same header, footer, and sidebars.  Facelets lets you encapsulate that commonality in a template, so that you can update the look of your site by making changes to the template, not the individual pages.  Facelets templates encapsulate functionality that is shared by multiple pages, so you don’t have to specify that functionality individually for each page. Encapsulation is the cornerstone of both object-oriented programming, and the well-known DRY (Don’t Repeat Yourself) principle.  My opinion: use CSS for layout

 When you place the ui:debug tag in a Facelets page, a debug component is added to the component tree for that page.  If the user types a hotkey, which by default is CTRL+SHIFT+d, JSF opens a window and displays the state of the component tree and the application’s scoped variables.

Facelets debug output

Examining the component tree and scoped variables  You can click on Component Tree or Scoped Variables, to show the component tree or the application’s scoped variables

Using ui:debug  The ui:debug tag is useful during development, so developers can instantly see the current page’s component tree and the application’s scoped variables  You will probably want to remove the tag in production.  For that reason, we recommend that you put the ui:debug tag in a template, where it is specified in one place, and shared among many views, instead of replicating the tag in each view’s XHTML page.

 Sometimes, to find out which part of a JSF page causes a stack trace, you may want to use the time-honored divide-and-conquer strategy of commenting out parts of the page to isolate the offending component.  Somewhat surprisingly, the XML comments are not useful for this purpose.  For example, if you comment out a button in an XHTML page, like this:

 JSF will process the value expression #{msgs.loginButtonText}, and place the result, as a comment, in the generated HTML page.  Assuming that #{msgs.loginButtonText} evaluates to Log In, you will see the following in the generated HTML page:  If the getLoginButtonText() method throws an exception, then the XML comments don’t help you at all.  Instead, use ui:remove, like this:

Handling Whitespace  The handling of whitespace in Facelets pages can be a bit surprising. By default, whitespace is trimmed around components. For example, consider the tags:  They are separated by whitespace (the newline after the h:outputText and the spaces before h:inputText ).  Facelets won’t turn that whitespace into a text component. This is a good thing—otherwise the tag sequence would not work correctly inside an h:panelGrid.  However, if you have two links in a row, the whitespace handling is unintuitive. The tags  Yield links PreviousNext with no space in between. The remedy is to add a space with a value expression #{' '}.

ui:repeat  The ui:repeat tag repeatedly inserts its body into the page.  Useful for data tables:

ui:repeat Attributes  The ui:repeat tag has several attributes that can make it a better choice than h:dataTable in some situations.  The following attributes let you iterate over a subset of the collection:  offse t is the index at which the iteration starts (default: 0)  step is the difference between successive index values (default: 1)  size is the number of iterations (default: (size of the collection – offset) / step)  For example, if you want to show elements 10, 12, 14, 16, 18 of a collection, you use:

More ui:repeat Attributes - varStatus  The varStatus attribute sets a variable that reports on the iteration status. The iteration status has these properties:  Boolean properties even, odd, first, and last, which are useful for selecting styles.  Integer properties index, begin, step, and end, which give the index of the current iteration and the starting offset, step size, and ending offset.  Note that begin = offset and end = offset + step × size, where offset and size are the attribute values from the ui:repeat tag.

More ui:repeat Attributes - index  The index property can be used for row numbers: