HTML and CSS Reference
In-Depth Information
It is also possible to use the square brackets ([ ]) instead of the (.) inside the value expressions. adding to
accessing managed bean properties, square brackets can be used for accessing maps and arrays as we saw in the
“Managed Beans” section examples.
Method Expression
A method expression can be used for executing public non-static methods of managed beans. Method expression can
be invoked from
action and actionListener attributes of the ActionSource (or ActionSource2 ) components
such as ( commandButton and commandLink ).
valueChangeListener attribute of the EditableValueHolder components such as ( inputText
and selectOneMenu ).
beforePhase and afterPhase attributes of the <f:view> tag.
In the firstApplication , we can modify the login commandButton 's action attribute to have a method expression
instead of the "welcome" String literal in the login page ( index.xhtml ) as shown in the bolded line in Listing 2-19.
Listing 2-19. The Modified Login Page
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns=" "
xmlns:ui=" "
xmlns:h=" " >
<ui:composition template="/WEB-INF/templates/simple.xhtml">
<ui:define name="title">
<ui:define name="content">
<h:commandButton value="#{bundle['application.login']}" action="#{user.login}"/>
The login() method in the User managed bean is simple, as shown in Listing 2-20.
Search WWH ::

Custom Search