开发者

<ui:param and caching

开发者 https://www.devze.com 2023-03-22 02:14 出处:网络
I have the following thing: <ui:param name=\"randomVideo\" value=\"#{bean.randomVideo}\" /> <a href=\"#{randomVideo.link}\">#{randomVideo.text}</a&></pre>

I have the following thing:

<ui:param name="randomVideo" value="#{bean.randomVideo}" />
<a href="#{randomVideo.link}">#{randomVideo.text}</a&></pre>

Because <ui:pa开发者_运维知识库ram> does not cache the variable, Bean.getRandomVideo() is called twice, and the worst part is that the .text and .link are from different videos. I have already tried <c:set and <f:param. They both do not set the variable, maybe because I'm with facelets (JSF2).

Any ideas?


Getters are supposed to be real getters, not containing any logic. So:

  • make your bean @RequestScoped
  • initialize the randomVideo field in @PostConstruct
  • let the getter only retrieve the randomVideo field of the bean.
0

精彩评论

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

关注公众号