8/8/2019 JSF Core Tags
1/59
1
Using JSFUsing JSF
Tag LibrariesTag Libraries
8/8/2019 JSF Core Tags
2/59
2
Two Tag Libraries
jsf_core Defines other JSF related tags
Independent of any rendering technology html_basic
Defines tags for representing common HTML userinterface components
JSP page need to declare them
8/8/2019 JSF Core Tags
3/59
3
Using Core TagsUsing Core Tags
8/8/2019 JSF Core Tags
4/59
4
Types of Core Tags
Event handling tags
Attribute configuration tag
Data conversion tags
Facet tag Localization tag
Parameter substitution tag
Tags for representing items in a list Container tag
Validator tags
Output tag
Container for form tags
8/8/2019 JSF Core Tags
5/59
5
Using Core TagsUsing Core TagsEvent Handling TagsEvent Handling Tags
8/8/2019 JSF Core Tags
6/59
6
Event Handling Tags and
Attributes or actionListener
attribute
Registers an action listener on a component or
valueChangeListener attribute Registers a value-change listener on a parent
component
Registers a PhaseListener instance on a
UIViewRoot component
8/8/2019 JSF Core Tags
7/597
Example: actionListener attribute
in chooseLocale.jsp (carstore)
8/8/2019 JSF Core Tags
8/598
Example:
in customerInfo.jsp (carstore)
carstore is a pacakge
FirstNameChanged is a class that implementsValueChangeListener interace
8/8/2019 JSF Core Tags
9/599
Using Core TagsUsing Core Tags
Attribute ConfigurationAttribute ConfigurationTagTag
8/8/2019 JSF Core Tags
10/5910
Attribute Configuration Tag
Adds configurable attributes (key/value pairs) to a
parent components
8/8/2019 JSF Core Tags
11/5911
Using Core TagsUsing Core TagsData Conversion TagData Conversion Tag
8/8/2019 JSF Core Tags
12/59
12
Data Conversion Tags
Registers an arbitrary converter on the parent
component
Registers a DateTime converter instance on theparent component
Registers a Number converter instance on the
parent component
8/8/2019 JSF Core Tags
13/59
13
Using Core TagsUsing Core TagsFacet TagFacet Tag
8/8/2019 JSF Core Tags
14/59
14
Facet Tag
Signifies a nested component that has a special
relationship to its enclosing tag
8/8/2019 JSF Core Tags
15/59
15
Using Core TagsUsing Core TagsLocalizationTagLocalizationTag
8/8/2019 JSF Core Tags
16/59
16
Localization Tag
Loads a resource bundle, stores properties as a
Map
8/8/2019 JSF Core Tags
17/59
17
Using Core TagsUsing Core Tags
Parameter SubstitutionParameter SubstitutionTagTag
8/8/2019 JSF Core Tags
18/59
18
Parameter Substitution Tag
Substitutes parameters into a MessageFormat
instance and to add query string name/value pairsto a URL
8/8/2019 JSF Core Tags
19/59
19
Using Core TagsUsing Core Tags
Tags for RepresentingTags for RepresentingItems in a ListItems in a List
8/8/2019 JSF Core Tags
20/59
20
Tags for Representing Items in a
List
Represents one item in a list of items in a
UISelectOne or UISelectMany component
Represents a set of items in a UISelectOne orUISelectMany component
8/8/2019 JSF Core Tags
21/59
21
Using Core TagsUsing Core Tags
Container TagContainer Tag
8/8/2019 JSF Core Tags
22/59
22
Container Tag
Contains all JavaServer Faces tags in a page that
is included in another JavaServer Faces page
8/8/2019 JSF Core Tags
23/59
23
Using Core TagsUsing Core Tags
Validator TagsValidator Tags
8/8/2019 JSF Core Tags
24/59
24
Validator Tags
Registers a DoubleRangeValidator on a
component
Registers a LengthValidator on a component
Registers a LongRangeValidator on a component
Registers a custom Validator on a component
8/8/2019 JSF Core Tags
25/59
25
Using Core TagsUsing Core Tags
Output TagsOutput Tags
8/8/2019 JSF Core Tags
26/59
26
Output Tags
Generates a UIOutput component that gets its
content from the body of this tag
8/8/2019 JSF Core Tags
27/59
27
Using Core TagsUsing Core Tags
Container for Form TagsContainer for Form Tags
8/8/2019 JSF Core Tags
28/59
28
element
Represents UIViewRoot component
All component tags on the page must be
enclosed in the view tag... other faces tags, possibly mixed with othercontent ...
Optional locale attribute
Overrides the Locale stored in the UIViewRoot
8/8/2019 JSF Core Tags
29/59
29
Nested View's
Use element in order toinclude a JSF page inside another JSP
page
jsp:include page="theNestedPage.jsp"
8/8/2019 JSF Core Tags
30/59
30
Using HTML Tags
8/8/2019 JSF Core Tags
31/59
31
HTML Tags
Used to control display data or accept datafrom the user
Common attributes id: uniquely identifies the component
value: identifies an external data source mappedto the component's value
binding: identifies a bean property mapped to thecomponent instance
8/8/2019 JSF Core Tags
32/59
32
Using HTML Tags
UIForm &
8/8/2019 JSF Core Tags
33/59
33
UIForm & tag
UIForm UI component An input form with child components representing
data that is either presented to the user orsubmitted with the form
Encloses all of the controls that display orcollect data from the user
Include HTML markup to layout the controlson the page tag itself does not perform any layout
8/8/2019 JSF Core Tags
34/59
34
Using HTML Tags
UICommand &
8/8/2019 JSF Core Tags
35/59
35
UICommand &
UICommand component performs an action
(submit requests) when it is activated
No need to use onchange to force form submitswith value change events
Most common renderers are Button andLink
8/8/2019 JSF Core Tags
36/59
36
UICommand &
Additional attributes
action: is either a logical outcome String or a JSF EL
expression that points to a bean method that returns alogical outcome String
In either case, the logical outcome String is used by thenavigation system to determine what page to accesswhen the UICommandcomponent is activated
actionListener: is a JSF EL expression that points to a bean method
that processes an ActionEventfired by the UICommandcomponent
8/8/2019 JSF Core Tags
37/59
37
Example1:
from carDetail.jsp
action attribute
references a method on the CarStore backing beanthat performs some processing and returns anoutcome
outcome is passed to the default NavigationHandler,which matches the outcome against a set of navigation
rules defined in the application configuration file. value attribute
references the localized message for the button's label
bundle part of the expression refers to the
ResourceBundle that contains a set of localizedmessages
8/8/2019 JSF Core Tags
38/59
38
Example1: buyCurrentCar()
method of CarStore.javapublic class CarStore extends Object {
... public String buyCurrentCar() {
getCurrentModel().getCurrentPrice();return "confirmChoices";}...
}
8/8/2019 JSF Core Tags
39/59
39
Example1: Navigation rule for
conformChoices in faces-config.xml
/carDetail.jspAny action that returns "confirmChoices" oncarDetail.jsp should cause navigation toconfirmChoices.jsp
confirmChoices/confirmChoices.jsp
8/8/2019 JSF Core Tags
40/59
40
Example1: Resources.properties
file of carstoresunroofLabel=SunroofcruiseLabel=Cruise ControlkeylessLabel=Keyless Entry
securityLabel=Security SystemskiRackLabel=Ski RacktowPkgLabel=Tow PackagegpsLabel=GPSbuy=Buyback=BackbuyLabel=Thanks for stopping by!
carDetail jsp
8/8/2019 JSF Core Tags
41/59
41
carDetail.jsp
confirmChoices jsp
8/8/2019 JSF Core Tags
42/59
42
confirmChoices.jsp
8/8/2019 JSF Core Tags
43/59
43
Example2:
from optionsPanel.jsp
optionsPanel.jsp is include'd insidecarDetails.jsp
optionsPanel jsp
8/8/2019 JSF Core Tags
44/59
44
optionsPanel.jsp
8/8/2019 JSF Core Tags
45/59
45
Example2: choosePackage()
method of CarStore.javapublic class CarStore extends Object {
...public void choosePackage(ActionEvent event) {
String packageName = event.getComponent().getId();choosePackage(packageName);}public void choosePackage(String packageName) {
// Business logic processing
}...}
8/8/2019 JSF Core Tags
46/59
46
action vs. actionListener
action Designed for business logic
Participate in navigation handling actionListener
Receives ActionEvent object as a parameter
Handles user interface logic
Does not participate in navigation
8/8/2019 JSF Core Tags
47/59
47
Using HTML Tags
UIInput & UIOutput
8/8/2019 JSF Core Tags
48/59
48
UIInput & UIOutput Components
UIInputcomponent displays a value to a userand allows the user to modify this data
The most common example is a text field UIOutputcomponent displays data that
cannot be modified The most common example is a label
Conversions can occur
Both UIInputand UIOutputcomponents canbe rendered in several different ways
8/8/2019 JSF Core Tags
49/59
49
UIInput Component and Renderer
Combinations inputHidden
Allows a page author to include a hidden variablein a page
inputSecret Accepts one line of text with no spaces and
displays it as a set of asterisks as it is typed
inputText Accepts a text string of one line
inputTextarea Accepts multiple lines of text
8/8/2019 JSF Core Tags
50/59
50
UIOutput Component and
Renderer Combinations outputLabel
Displays a nested component as a label for aspecified input field
outputLink Display an tag that links to another page
without generating an ActionEvent
outputMessage Displays a localized message
outputText Displays a text string of one line
8/8/2019 JSF Core Tags
51/59
51
Attributes of and
id
value
converter validator
JSF EL expression pointing to a backing-beanmethod that performs validation on the
component's data valueChangeListener
a JSF EL expression that points to a backing-bean method that handles the event of entering a
value in this component
8/8/2019 JSF Core Tags
52/59
52
Example: in
customerInfo.jsp
customerInfo.jsp
8/8/2019 JSF Core Tags
53/59
53
customerInfo.jsp
8/8/2019 JSF Core Tags
54/59
54
Using HTML Tags
UIPanel &
8/8/2019 JSF Core Tags
55/59
55
UIPanel Component
Is used as a layout container for its children
Must have the number of rows
predetermined
8/8/2019 JSF Core Tags
56/59
56
UIIPanelComponent and Renderer
Combinations panelGrid
Displays a HTML table
Used to display entire table Render attributes are
columnClasses, columns, footerClass, headerClass,panelClass, rowClasses
panelGroup Groups a set of components under one parent
Used to represent rows in the tables
8/8/2019 JSF Core Tags
57/59
57
confirmChoices.jsp
...
...
confirmChoices.jsp
8/8/2019 JSF Core Tags
58/59
58
confirmChoices.jsp
8/8/2019 JSF Core Tags
59/59
Questions?Questions?
Top Related