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.
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?
You have basically two options:
Don't navigate by ajax. Instead, navigate by GET. See also How to navigate in JSF? How to make URL reflect current page (and not previous one).
Or, don't conditionally render content. Instead, conditionally build content. See also How to ajax-refresh dynamic include content by navigation menu? (JSF SPA)