Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF getter methods called BEFORE beforePhase fires
    text
    copied!<p>I got a recommendation to put all data lookups in the beforePhase for a given page, however, now that I am doing some deeper analysis it appears that some getter methods are being called before the beforePhase is fired. </p> <p>It became very obvious when I added support for a url parameter and I was getting NPEs on objects that are initialized in the beforePhase call. </p> <p>Any thoughts? Something I have set wrong.</p> <p>I have this in my JSP page:</p> <pre><code>&lt;f:view beforePhase="#{someController.beforePhaseSummary}"&gt; </code></pre> <p>That is only the 5th line in the JSP file and is right after the taglibs.</p> <p>Here is the code that is in the beforePhaseSummary method:</p> <pre><code>public void beforePhaseSummary(PhaseEvent event) { logger.debug("Fired Before Phase Summary: " + event.getPhaseId()); if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) { HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); if (request.getParameter("application_id") != null) { loadApplication(Long.parseLong(request.getParameter("application_id"))); } /* Do data fetches here */ } } </code></pre> <p>The logging output above indicates that an event is fired. The servlet request is used to capture the url parameters. The data fetches gather data. However, the logging output is below:</p> <pre><code>2010-04-23 13:44:46,968 [http-8080-4] DEBUG ...SomeController 61 - Get Permit 2010-04-23 13:44:46,968 [http-8080-4] DEBUG ...SomeController 107 - Getting UnsubmittedCount 2010-04-23 13:44:46,984 [http-8080-4] DEBUG ...SomeController 61 - Get Permit 2010-04-23 13:44:47,031 [http-8080-4] DEBUG ...SomeController 133 - Fired Before Phase Summary: RENDER_RESPONSE(6) </code></pre> <p>The logs indicate 2 calls to the getPermit method and one to getUnsubmittedCount before the beforePhase is fired.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload