JSF 2.0, preRenderView event handler called twice

I have the following snippet:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

<f:metadata>
    <f:event type="preRenderView" listener="#{workflowController.test}"/>
</f:metadata>

<h:head>
    <title>Simple JSF Facelets page</title>
</h:head>

<h:body>
    Hello, Place your content here
</h:body>

</html>

When I open the page, the WorkflowController.test () method is called twice (this is just a simple method that makes a log entry). Do you know why he is called twice?

Thank.

+3
source share
1 answer

Try to put the tag <f:event/>outside <f:metadata>, it worked for me (mojarra 2.1.0).

+5
source

All Articles