Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

f:viewAction is not invoked

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());
    }
}
like image 655
user1863488 Avatar asked Mar 22 '23 03:03

user1863488


1 Answers

Fixed by changing the namespaces from http://xmlns.jcp.org/jsf/ to http://java.sun.com/jsf/

like image 195
user1863488 Avatar answered Mar 23 '23 17:03

user1863488