Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7038837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:43:02+00:00 2026-05-28T01:43:02+00:00

A page/bean of mine has its preRenderView event fired twice on the first page

  • 0

A page/bean of mine has its preRenderView event fired twice on the first page load then 2 + n times for each postback, where n is the number of postbacks (including the current one) that have occurred.

After reading a few other posts here, I moved <f:event type="preRenderView" listener="myBean.preRenderView"/> outside of <f:metadata/> and that reduced the number of preRenderView calls by one. That is, it is called once on the full page load and 1 + n times for each postback. I even tried to move the <f:event/> tag outside of <f:view/>, but it had no effect.

I’m not sure if this is relevant: The page uses a template:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:fb="http://www.facebook.com/2008/fbml">
    <f:view contentType="text/html">
        <ui:insert name="metadata"/>
        <h:head>
            <!-- Some stuff here -->
            <ui:insert name="content"/>
            <!-- More stuff here -->
        </h:head>
        <h:body>
        </h:body>
    </f:view>
</html>

And the relevant bits of the page:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title></title>
    </h:head>
    <h:body>
        <ui:composition template="/WEB-INF/templates/myLayout.xhtml">
            <ui:define name="windowTitle">My Page</ui:define>
            <ui:define name="metadata">
                <f:event type="preRenderView" listener="#{myBean.preRenderView}"/>
            </ui:define>
            <ui:define name="content">
                <!-- Some content here -->
                <h:panelGroup id="reRenderable" layout="block">
                    <!-- More content here -->
                    <h:form prependId="false">
                        <h:outputLabel for="mySelector" value="Item:"/>
                        <h:selectOneMenu id="mySelector"
                                         value="#{myBean.item}"
                                         converter="#{myConverter}"
                                         validator="#{itemActiveValidator.validate}">
                            <f:selectItems value="#{myBean.myItems}"/>
                            <f:ajax render=":reRenderable"/>
                        </h:selectOneMenu>
                    </h:form>
                    <!-- More content here -->
                </h:panelGroup>
                <!-- More content here -->
            </ui:define>
        </ui:composition>
    </h:body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:43:03+00:00Added an answer on May 28, 2026 at 1:43 am

    It looks like yet another Mojarra bug: JAVASERVERFACES-2162

    I applied the workaround as follows and it works:

    <ui:define name="metadata">
        <f:metadata>
            <f:viewParam name="dummy"/>
            <f:event type="preRenderView" listener="#{myRecordsBean.preRenderView}"/>
        </f:metadata>
    </ui:define>
    

    All that’s left to do is push dummy up to the template to keep the pages that use it free from this filth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this in a page: <f:event type=preRenderView listener=#{bean.logoutIfNotAuthenticated}/> it works. However, the
I have a jsp page which has dynamic includes. each dynamic include invoke its
How to set a bean property from jsf page before executing this f:event listener:
I have a page index.jsp that has this snippet in it <bean:message key=label.username />
I have an JSF page backed by NewsBean.java which has <f:event type=preRenderComponent listener=#{newsBean.init} />
I have two drop downs on a page whose backing bean is Request Scoped.
I have a page that is backed by a ViewScoped Managed Bean. The page
I am working on a jsp page which uses a bean to create an
I am able to get the current page's url in jsf from back-end bean
Is there a way to execute a JSF managed bean action when a page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.