3

I have a tabPanel with some tabs, and same tabs have a number (counter) ex. Accounts(2), I want to reRender the label of account tab to update the number of accounts when I add new account. I used the following code, but when I click on Add button, tab content disappear and nothing change.

Controller

public Integer AccountsNo {set; get;}
public list<Account> accounts {set; get{
 return [Select id,Name,Address from Account];
};}

public pageReference addAccount(){
       insert account;
       accounts.add(account);
       AccountsNo = accounts.size();

       return null;
}

in VF page

<apex:tab label="Accounts{!AccountsNo}" id="accountTab">

  // form of Required fields
  <apex:commandButton action="{!addAccount}" reRender="accountTab,accountsTable" />

  <apex:pageBlockTable id="accountsTable" ... >
  // Table code
  </apex:pageBlockTable>

</apex:tab>

2 Answers 2

1

Make this part of a form and try to rerender the whole form.

<apex:page>
 <apex:form id="pgfrm">
   <apex:tab label="Accounts{!AccountsNo}" id="accountTab">

      // form of Required fields
   <apex:commandButton action="{!addAccount}" reRender="pgfrm,accountsTable" />

    <apex:pageBlockTable id="accountsTable" ... >
       // Table code
    </apex:pageBlockTable>

    </apex:tab>
 </apex:form>
</apex:page>
1
  • Your welcome :> Commented Jan 29, 2014 at 12:19
0

I think that you should wrapper the apex:tab using a apex:outputPanel and rerender that.

I've tried and works

<apex:outputPanel id="wrapper">
<apex:tab label="Accounts{!AccountsNo}" id="accountTab">

  // form of Required fields
  <apex:commandButton action="{!addAccount}" reRender="wrapper" />

  <apex:pageBlockTable id="accountsTable" ... >
  // Table code
  </apex:pageBlockTable>

</apex:tab>
</apex:outputPanel>
3
  • Error: Unknown component apex:outpanel Commented Jan 29, 2014 at 12:16
  • sorry, was a typo: apex:outputPanel Commented Jan 29, 2014 at 12:29
  • I used outputPanel too, but the tab disappeared from the tabs bar Commented Jan 29, 2014 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .