Facelet label performance

I have a file with a lot of content. For example, when displaying a user profile, every EL expression in is the same. Need userId as a bean The parameter is taken from the session context. I declare this userId in the xhtml file as

I passed this userId to the bean method as






I predict that the session variable will be called once to the page. But it will be called every time the userId is processed sessiion variable. Is this correct behavior? How to optimize this?

Yes, this is the correct behavior. It will be interesting to see which is faster. I guess It will be faster to inject currentUser in your profile component and then retrieve the correct object from there instead of getting the address and contact of the userId every time. (depending on whether you cache it in the component).

However, I will try to optimize it by injecting currentUser into the profile component. This is the standard way of doing this.

I There is a file that contains a lot of content. For example, when displaying a user profile, every EL expression in is the same. The userId is required as a parameter of the bean, which is taken from the session context. I’m in Declare this userId in the xhtml file as

I passed this userId to the bean method as


< h:outputText value="#{profile.getContact(userId)}"/>



I predict that the session variable will be called once to the page. But the sessiion variable will be called every time the userId is processed. Is this correct behavior? How to optimize this?

Yes, this is the correct behavior. It will be interesting to see which is faster. I guess injecting currentUser in your profile component will be faster And then retrieve the correct object from there instead of getting the address and contact of the userId every time. (depending on whether you cache it in the component).

However, I will try Optimize it by injecting currentUser into the profile component. This is the standard way to do this.

Leave a Comment

Your email address will not be published.