In the last row of our grid, we added an empty <h:panelGroup> tag. The purpose
of this tag is to allow adding several tags into a single cell of an <h:panelGrid> .
Any tags placed inside this tag are placed inside the same cell of the grid where
<h:panelGrid> is placed. In this particular case, all we want to do is to have an
"empty" cell in the grid so that the next tag, <h:commandButton> , is aligned with the
input fields in the rendered page.
<h:commandButton> is used to submit a form to the server. The value of it's value
attribute is used to generate the text of the rendered button. The value of it's action
attribute is used to determine what page to display after the button is pressed. This
is specified in the navigation rules of the application's faces-config.xml file, which
will be covered later in the chapter.
In our example, we are using static navigation . When using JSF static navigation,
the value of the action attribute of a command button is hard coded in the JSP
markup. An alternate to static navigation is dynamic navigation . When using
dynamic navigation, the value of the action attribute of the command button is a
value binding expression resolving to a method returning a String in a managed
bean. The method may then return different values based on certain conditions.
Navigation would proceed to a different page, depending on the value of
As long as it returns a String , the managed bean method executed
when using dynamic navigation can contain any logic inside it, and is
frequently used to save data in a managed bean into a database.
Both when using static or dynamic navigation, the page to navigate to is defined in
the application's faces-config.xml configuration file. Later in this chapter, we will
explain how we can graphically configure navigation rules using the NetBeans Page
Creating Our Managed Bean
JSF-managed beans are standard JavaBeans that are used to hold user-entered data
in JSF applications. JSF-managed beans need to be declared in the application's
faces-config.xml file. NetBeans can help expedite things by automatically adding
our managed beans to faces-config.xml .