HTML and CSS Reference
In-Depth Information
public String rejectRequest() {
BookRequest currentBookRequest = getSelectedBookRequest();
try {
bookRequestManager.rejectBookRequest(currentBookRequest.getId());
infoMessage = "Book Request Rejected";
} catch (BookRequestNotFound ex) {
Logger.getLogger(BookRequestsBacking.class.getName()).log(Level.SEVERE, null, ex);
getContext().addMessage(null, new FacesMessage("An error occurs while rejecting book
request"));
}
return null;
}
}
The main methods of
BookRequestsBacking
CDI bean are as follows:
•
retrieveBookRequests
: Calls
viewRequests
method of
BookRequestManager
EJB passing the
logged in user ID and requests list type (0 for pending, 1 for rejected, and 2 for approved) as
parameters. If there is no results returned, a
"No Requests found"
message is displayed to
the user. If results are returned, a message with the number of returned requests is displayed,
including the requests list.
•
downloadBook
: Calls
getBookContent
method of
BookManager
EJB passing the currently
selected book ID (using
getSelectedBookRequest().getBookId()
) as a parameter; and in
order to give the downloadable content a meaningful name, the topic title is retrieved using
getBookInformation
method of
BookManager
EJB.
•
approveRequest
: Calls
approveBookRequest
method of
BookRequestManager
EJB passing the
book request ID as a parameter. If the operation succeeds, then the following
"Book Request
Approved"
message will be displayed to the user.
•
rejectRequest
: Calls
rejectBookRequest
method of
BookRequestManager
EJB passing the
book request ID as a parameter. If the operation succeeds, then the following
"Book Request
Rejected"
message will be displayed to the user.
■
Currently in early builds of Mojarra 2.2,
<f:viewParam>
does not work if you use the new JSF 2.2
namespace,
"
http://xmlns.jcp.org/jsf/core
"
. in order to fix this issue, just use the old JSF core namespace,
Caution
Now, it is the time to move to the administrator pages. Listing 13-30 shows
bookAdd.xhtml
, which is used for
adding new books by the administrator.
Listing 13-30.
bookAdd.xhtml Page
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="
http://www.w3.org/1999/xhtml
"
xmlns:ui="
http://xmlns.jcp.org/jsf/facelets
"
xmlns:h="
http://xmlns.jcp.org/jsf/html
"
xmlns:f="
http://xmlns.jcp.org/jsf/core
"
>
