I am using Glassfish 4 with jsf 2.2, and I have the following code on 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 method is findByIdnever called (I added a write instruction there and nothing is printed, the private member remains empty).
This page is called from another page as follows:
<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 BookController code:
@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());
}
}
source
share