Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF 2.0, "preRenderView" event handler called twice

Tags:

jsf-2

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 (it's just a simple method which makes a log entry). Do you know why it's being called twice?

Thanks.

like image 251
Ariod Avatar asked May 20 '11 09:05

Ariod


1 Answers

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

like image 188
baraber Avatar answered Nov 14 '22 15:11

baraber