TabView primefaces 3.1 Reload a page inside a tab and call again the ManagedBean

Go To StackoverFlow.com

0

I need some help, I'm using primefaces 3.1 and doing some pages, and I want to load this pages into a tabview, and each page depends of each other.

Like This.

<p:tabView id="tabView1">
        <p:tab id="tabInfo" title="title1">
            <ui:include src="page1.xhtml"/>
        </p:tab>
        <p:tab id="tab2" title="title2" >
            <ui:include src="page2.xhtml"/>
        </p:tab>
        <p:tab id="tab3" title="title3">
            <ui:include src="page3.xhtml"/>
        </p:tab>
    </p:tabView>

page 2 depends form page 1 for making some validations and present or not the page 2 this information, page3 need the same.

How can I do for when I select tab2 call again the ManagedBean of page 2 and reload page 2 and make that validations and present the data?.

This validations and all the serach of the information is on the init Method.

Please help me with this.

And I apologize for my poor english.

Thanks,

2012-04-04 20:34
by lion316


2

You need to add something like this to your tabView:

<p:tabView id="tabView1">
     <p:ajax event="tabChange" listener="#{yourBean.onTabChange}" update=":tab2"/>
...
  • event: defines what should happen to start the ajax request
  • listener: will be notified if the event happens
  • update: does a re-render on the given id

Update to answer your comment:

The method onTabChange could look like this:

public void onTabChange(TabChangeEvent event) {  
    // ... 
} 

event provides the selected tab:

event.getTab()

you could now rerender all of your tabs with:

... update=":tabInfo, :tab2, :tab3"

or you store the selected tab in your bean and do something like this:

... update="#{yourBean.selectedTab}"

where selectedTab would look like this:

public String getSelectedTab(){
     // selectedTab is a variable that should be set onTabChange()
     return selectedTab;
}
2012-04-04 20:47
by SWoeste
Thanks for your answer, but what happen If I need to reload page on tab3, and what should be inside method onTabChange - lion316 2012-04-04 21:04
I extended my answer a bit .. - SWoeste 2012-04-04 21:16
Thanks very much I would try this - lion316 2012-04-04 22:11
Ads