I'm using Glassfish 4 with jsf 2.2 and I have the following code in one of my jsf pages:
<ui:composition template="resources/admin_layout.xhtml">
<f:metadata>
<f:viewParam name="bookId" value="#{bookController.bookId}"/>
<f:viewAction action="#{bookController.findById}"/>
</f:metadata>
...
</ui:composition>
The problem is that the findById
method is never called (I added a logging statement there and nothing is printed, the private member remains null).
This page is called from the other page the following way:
<h:form>
<h:button value="update" outcome="update_book.xhtml">
<f:param name="bookId" value="#{book.id}"/>
</h:button>
</h:form>
Here is the simplified code of the BookController:
@Model
public class BookController {
@EJB
private BookEjb be;
@Inject
private Logger logger;
private Book book;
private Long bookId;
public Long getBookId() {
return bookId;
}
public void setBookId(final Long id) {
bookId = id;
}
public void findById() {
book = be.findById(bookId);
logger.log(Level.INFO, "Found book with title: {0}", book.getTitle());
}
}
Fixed by changing the namespaces from http://xmlns.jcp.org/jsf/ to http://java.sun.com/jsf/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With