如何在与有条件渲染的内容相关联的页面加载时不初始化Bean [英] How to NOT initialize beans on page load associated with conditionally rendered content

查看:128
本文介绍了如何在与有条件渲染的内容相关联的页面加载时不初始化Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中有条件渲染的内容由侧面菜单中的多个链接控制.所有这些内容都有一个默认情况下为false的数据表.一切正常,除了在页面加载时所有Bean正在执行并且所有Bean都在执行昂贵的数据库工作.

I have a single page with conditionally rendered content controlled by several links in a sidemenu. All of that content has a datatable that is rendered false by default. Everything is working, except that when the page loads all of the beans are being executed and all beans are doing expensive database work.

我希望当用户单击侧面菜单时,将呈现相应的数据表,然后才初始化关联的托管Bean.我该如何实现?

I would like that when a sidemenu is clicked by user, the corresponding datatable will render and only then the associated managed bean will be initialized. How can I achieve this?

推荐答案

您基本上有两种选择:

  1. 不要通过ajax导航.而是,通过GET导航.另请参见或者,不要有条件地呈现内容.而是有条件地构建内容.另请参见如何对Ajax刷新动态包含内容通过导航菜单? (JSF SPA)

    Or, don't conditionally render content. Instead, conditionally build content. See also How to ajax-refresh dynamic include content by navigation menu? (JSF SPA)

    这篇关于如何在与有条件渲染的内容相关联的页面加载时不初始化Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆