EL (Expression Language, those {} things) won't cache the result of the calls or so. It just accesses the data straight in the bean. This does normally not harm if the getter just returns the data.
EL (Expression Language, those #{} things) won't cache the result of the calls or so. It just accesses the data straight in the bean. This does normally not harm if the getter just returns the data.
The setter call is done by @ManagedProperty. It basically does the following: selector. SetProfilePage(request.
GetParameter("profilePage")); The getter calls are all done by rendered="#{selector. ProfilePage == 'some'}" during the render response phase. When it evaluates false the first time, in UIComponent#encodeAll(), then no more calls will be done.
When it evaluates true, then it will be re-evaluated six more times in the following sequence: UIComponent#encodeBegin() - Locates renderer for the begin of component. Renderer#encodeBegin() - Renders begin of component. UIComponent#encodeChildren() - Locates renderer for children of component.
Renderer#encodeChildren() - Renders children of component. UIComponent#encodeEnd() - Locates renderer for end of component. Renderer#encodeEnd() - Renders end of component.
The component and its renderer verifies during every step if it is allowed to render. True, this look like clumsy and inefficient. It's after all also the achilles heal of JSF.
Actually, an issue was reported to JSF dev team: issue 1253. It's been suggested to remove all those repeated checks and stick to the one done in UIComponent#encodeAll(). This may however require major changes in the API.
If your concern is that the managed property should be checked only once after its setting if it's null or empty, then consider to move it into a method which is annotated with @PostConstruct. Such a method will be called directly after bean's construction and all dependency injection. @PostConstruct public void init() { if (profilePage == null || profilePage.trim().isEmpty()) { profilePage = "main"; } } See also: Why JSF calls getters multiple times?
Yes, but how I have specified, I have only one #{selector. ProfilePage} in only one page. Thats what I don't understand :) – markzzz Nov 25 '10 at 23:53 1 I haven't observed the behaviour in JSF 2.0 closely, it isn't worth the effort so microoptimize it since it's particularly cheap, but you may want to add a Thread.dumpStack(); to the getter to learn where this call originates and a sysout of FacesContext.
GetCurrentInstance().getPhaseId() to learn which phase it's sitting in now. – BalusC Nov 25 '10 at 23:55 Uhm ok, so is more complicate to understand this :) I think I shouldn't mind about it when programming on jsf (just I wanted to know if I done somethings wrong). But seems to happen to all.So ok, I initialize it after PostConstruct :) – markzzz Nov 26 '10 at 0:00 Added an example.
If this topic will be closed, or the question is unrelated, i'll open a new one :) Let me know – markzzz Nov 26 '10 at 0:15 Nice one man :) So, if I use @ManagedProperty (that such as selector. SetProfilePage(request. GetParameter("profilePage"));) and I use this value only to get param (not my case) I could remove the public void setProfilePage(String profilePage) { this.
ProfilePage=profilePage; } (i won't do it, its a bean, maybe i'll use this in a future). Now is clear why it calls many times the getter method :) What I don't understand is why my code still doesn't work properly : I must click many time in the button to set profilePage attribute (the ajax call start, but seems that bean doesn't update itself – markzzz Nov 26 '10 at 17:28.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.