Home > > JSF Lifecycle

JSF Lifecycle

Hello all,
I am experiencing the following problem:
Imagine that there is a managed bean with scope = "request", called "bean". There is a page X that has a couple of properties bound to this bean:
* commnandButton id="myButton" rendered="#{bean.buttonRendered}"
* inputText value="#{bean.textValue}"
And so on. When we navigate TO page X, we create the request scoped bean and fill the required properties in (e.g. bean.setTextValue("This is a test"); ).
Now let the isButtonRendered method behave like this:
if (getTextValue().equals("This is a test"))
return true;
return false;
The problem is, that when we click the "myButton" button, the isButtonRendered() method of the bean is called before the request values are applied to the bean. So, textValue is still null and thus, a NullPointerException occurs in the isButtonRendered method.
Could you please tell me why the isButtonRendered() method is called? Why does the JSF framework need this value before the values are applied, and how is this very frequently occurring problem worked around in practice?
Best Regards,
And there is something significantly more important:
Imagine you have the following binding:
and you click the button. Then you immediately get a NullPointerException in the Validation Phase, because the bean.someObject is null!!!!
Please help - I am trying to get something extremely fundamental - a master-detail relationship between pages. In the master page, you have a datatable and when you click on some item, you are sent to a detail page that allows editing of the selected item. The bean behind the detail page is with request scope. Thus, I keep the ID of the selected item in a inputHidden field. However, when you click "Save" on the detail page, a NullPointerException occurs in the validation phase, because when validation occurs, the setter method of the hidden fields has not yet been called and someObject is null.
Do you have any idea how to solve this task?
Any help will be greatly appreciated. Thank you all in advance!
Best Regards,
Read the other 5 answers
In our performance test we encountered a high cpu usage (100%) and the thread dumps indicated that most of the times the threads are either executing restore view or render response phase of the JSF lifecycle or they are blocked while accessing the j
hi, i want to know what does the scriptcollector do and how does it related to jsf lifecycle? and also in the scriptcollector if i call this, preRender=#{myBean.onPageLoadBegin} postRender=#{myBean.onPageLoadEnd} how my page will react?The hx:scriptC
1> Create a index.html page which loads menu.jsp in frame 1 and search.jsp in frame 2 2> menu.jsp --- define target as frame 2. Insert a command button, the action event of which re-loads search.jsp in frame 2 3> search.jsp ---- insert one input
Dear all, I found that my application is sucked at the Apply Request Values Phase of JSF lifecycle when I submit the page. (Totally spend 1 min to pass this phase) In the application, there is around 300 input fields in the page. Who know how can I e
I have created my own phase listener : public class MyPhaseListner implements PhaseListener { public void afterPhase(PhaseEvent evt) { System.out.println("EXITING : " + evt.getPhaseId()); public void beforePhase(PhaseEvent evt) {       System.ou
I have read through some documenation for the JSF lifecycle, I am wondering though how you would really take advantage of it? One of the purposes of JSF was to insulate the developer from having too know much about HTTP. However, how much do they rea
Where in the JSF lifecycle does submittedValue, localVaue and value get set? I was looking at those values on a hidden input field and it was not clear to me in what phases the various values get set. It seemed like sometimes one was set, sometimes t
Why does a valueChangeListener on a selectOneChoice fire in the JSF Lifecycle when I click on a separate non-related commandButton that runs an actionListener? How do I prevent a valueChangeListener to not fire when I click on a commandButton that ru
I need to find out why using an <iframe> element in my jsp page under JSF (with or without a <verbatim> tag SHORT-CIRCUITS THE JSF LIFECYCLE? ie: it goes right to after renderresponse completely bypassing validation and data binding!! PLEASE H
Was just having look at logs of a JSF application, below are the output's from PhaseListener RESTORE_VIEW(1) APPLY_REQUEST_VALUES(2) RESTORE_VIEW(1) RENDER_RESPONSE(6) How come RESTORE_VIEW is called after APPLY_REQUEST_VALUES, from JSF lifecycle it
As a JSF newbie, I ran into an unexpected component binding state/JSF lifecycle issue. Given this JSP code: <h:inputText id="boundinput" binding="#{UserBean.boundInput}">and this Java setter code:        private UIInput boundInpu
Hi all, Presently i am working on JDeveloper 11g. I want to customize JSF PageLifecycle in my project for customizing error messages to get proper error messages to the client. Can anybody help me ?This question has been ask here before. Have you sea
Ok, so just trying to get my head around this. The JSF architecture stores a lot of UI info in the session. Now this can be stored client or server side but the server side is default. I am wondering what would happen if the serlvet HttpSessions were
I have a request scoped jsf managed bean called "ManagedBean". This bean has a method annotated with "@PostConstruct" that retrieves data from a database. The data is shown in a jsp "showAndEditData.jsp" in <h:inputText /&
Hi My JSF application contains about 6 different jsp pages. Each of these jsp pages contains several richfaces components. Hence for example, in my home.jsp page, clicking on the LHS menu(commandButtons etc) will result in different content appearing
Hello, I am having Export functionality in my application, When I do export on click of "Export" button (h:commandButton) it works fine and it shows the excel file and allow me to save in my computer. After that when I call another functionality
Hello, I was wondering how i can interfere into the render response phase. The problem is that i'm using a richfaces component responsible for polling. When changing the contents of a div (it's a wizard-like behaviour) the reponse is added/rendered i
Hi all, I would like to ask 2 questions on JSF 1.2 lifecycle: All the requests for jsf resources are managed by the FacesServlet whose service method starts the lifecycle for the requested resource. So, for each request: the web container creates a n
Hi All, I am reading about JSF Lifecycle and I wanna know if I understood it correctly. I am writing down what I have understood from the phases, can someone please correct me if I am wrong? 1).*Restore view:* For the client side html page's request