Rich TabPanel's getters invoked when tab content not rendered

て烟熏妆下的殇ゞ 提交于 2019-12-03 20:44:00

The tabPanel has an attribute called selectedTab that calls a getter/setter every time a tab is selected. You could use the setter method to refresh the data when a specific tab is selected. You could also prevent the calling of getter methods within each tab by wrapping the content of the tab within a c:if element, which stops that segment of the html if the test returns false. For example:

<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:rich="http://richfaces.org/rich
    xmlns:c="http://java.sun.com/jstl/core">
    <rich:tabPanel selectedTab="#{pageScopedBean.selectedTab}">
        <rich:tab id="particularTab" label="A Tab">
            <c:if test="#{pageScopedBean.selectedTab eq 'particularTab'}">
                <!-- tab contents -->
            </c:if>
        </rich:tab>
    </rich:tabPanel>
</ui:composition>

Then within the Java, create getter and setter methods on pageScopedBean:

@Name("pageScopedBean")
@Scope(ScopeType.PAGE)
public class PageScopedBean {
    private String selectedTab = "";
    public String getSelectedTab() {
        return selectedTab;
    }
    public void getSelectedTab(String selectedTab) {
        this.selectedTab = selectedTab;
        if (this.selectedTab == "particularTab") {
            // refresh table
        }
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!