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 6369049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:45:12+00:00 2026-05-25T00:45:12+00:00

In my JSF2 application I have a phaselistener that needs to be executed before

  • 0

In my JSF2 application I have a phaselistener that needs to be executed before RENDER_RESPONSE but after JSF has built the viewroot.

First, what I did is register my PhaseListener in faces-config. The listener then gets called, but when I perform the beforePhase, getViewRoot().getChildren() is still empty.

Secondly, I found how to do this by adding the following on my xhtml pages:

<f:phaseListener type="be.application.PolicyController" />

This works fine, but adding this to each of my pages would be extremely tedious.
Hence I’m looking for a possibility to do this once for my application.

Any ideas how this can be done?

  • 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-25T00:45:13+00:00Added an answer on May 25, 2026 at 12:45 am

    Register a system event listener for the PreRenderViewEvent in faces-config:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
        version="2.0">
    
        <application>
            <system-event-listener>
                <system-event-listener-class>test.PreRenderViewListener</system-event-listener-class>
                <system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
            </system-event-listener>
        </application>
    
    </faces-config>
    

    Example of a listener:

    public class PreRenderViewListener implements SystemEventListener {
    
        @Override
        public void processEvent(SystemEvent event) throws AbortProcessingException {
            UIViewRoot root = (UIViewRoot) event.getSource();
            System.out.println(root.getChildCount());
        }
    
        @Override
        public boolean isListenerForSource(Object source) {
            return true;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF 2.0 application running on GlassFish v3. It has EJBs that
I have a JSF2 application that uses Spring 3.0. I have a bean that
I have a JSF 2.0 application that I would like to start adding validators
I have a web application written in JSF2 that uses Spring. I need to
I have some problem's with a simple application in JSF 2.0. I try to
My JSF2 application is fully internationalized, using a ResourceBundle. Now i have a lot
I have simple JSF2 application running on glashfish 3.1. I want to add a
I have a JSF2 application and a page with the following code: <h:inputText id=someInput
Our application is JSF2 based and we are desiging a exception handling for that.
I have a JSF 2 application which creates some SVG content. How can i

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.