I have a home
page:
<f:metadata>
<f:viewAction action="#{booksBean.selectBook()}"/>
</f:metadata>
<h:head>
<title>home</title>
</h:head>
<h:body>
...
<h:link >
<h:graphicImage name="images/books/s1.jpg" />
<f:param name="isbn" value="25413652" />
</h:link>
...
</h:body>
When user clicks on link, the isbn
value has been sent to booksBean.selectBook()
correctly.
But problem is when user navigates from login
page to home
page,
Here is userBean.login()
:
public String login() {
if (loginSuccessfully) {
return "home?faces-redirect=true"; // problem
} else {
//show error message
}
}
Problem is in mentioned section, when user moves to home.xhtml
the booksBean.selectBook()
is called automatically, and since it is null yet, i got NullPointerException
.
How can i go to home
page from login
page without invoking the booksBean.selectBook()
?