开发者

JSF -- Alternative to "rendered="?

We're developing a Java web app that utilizes JSF (Richfaces through Seam) for its UI. I've read several articles that indicate that using the "rendered=" attribute on UI components results in a pretty substantial performance hit. We have several components that we'd like to enable or disable based on whether or not their values are set. For example, if we're displaying an item for sale we wouldn't have a bunch of blank fields for attributes that are not set.

Given this performance hit, however, we're apprehensive about using multiple "rendered" fields. Is there a better performing alternative to this? Is there anything we can do to improve the performa开发者_开发知识库nce of using this field?


If the getter does nothing else than just returning a (cached) boolean property, then I really don't see any pains. There's no alternative to it. Best what you could to to improve the performance is to cache it in either the model (lazy loading) or the view (c:set). The cost of getter method invocation in turn is fully negligible.


Any other way wouldn't be free anyways.. so I would just use the standard JSF way to hide/show components.


You can use the style="display : (#{bean.booleon} ? block : none)" JSF tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜