HTML and CSS Reference
In-Depth Information
Error Handling
In order to display proper error pages when an error occurs, the following error codes are mapped to the indicated
pages in
web.xml
as shown in Listing 13-37.
Listing 13-37.
Error Codes Mapping in web.xml File
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="
http://xmlns.jcp.org/xml/ns/javaee
"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/javaee
version="3.1">
...
<error-page>
<error-code>404</error-code>
<location>/login.xhtml</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/public/pages/error.xhtml</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/public/pages/forbidden.xhtml</location>
</error-page>
...
</web-app>
When error
404
(
Resource not found
) occurs, the user is redirected the
login.xhtml
page; when error
500
(
Internal server error
) occurs, the user is redirected to
error.xhtml
page; and finally when error
403
(
Forbidden
access
) occurs, the user is redirected to
forbidden.xhtml
.
Composing JSF Components
In Mega App Facelets pages, there are some cases in which we can create JSF composite components in order to
simplify creating page elements and have the ability to reuse these components in further cases. One of these cases
is the navigation bar which is mentioned in Listing 13-18. In this section, we will create a navigation bar composite
component in order to simply the code of the header page.
<projsfhtml5:navbar>
composite component is a wrapper for bootstrap navigation bar that can be used as
shown in Listing 13-38.
Listing 13-38.
projsfhtml5:navbar Component
<html xmlns="
http://www.w3.org/1999/xhtml
"
xmlns:ui="
http://xmlns.jcp.org/jsf/facelets
"
xmlns:projsfhtml5="
http://xmlns.jcp.org/jsf/composite/projsfhtml5
"
>