function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sayanasreekanth@gmail.comsayanasreekanth@gmail.com 

Trying to store a value when a tab is clicked on VF page

 

Hi

I am trying to store a value in the custom object field through the controller. whenever a visualforce main tab is clicked. I have 2 tabs and for each tab there are 2 subtabs. I wrote the onclick="callcon('tabname') on the main tab and gaved the apexaction:function. but when i click the maintab the value is getting stored for the subtabs.the onclick functionality which i wrote for maintab is working for subtabs not for maintabs For eg when i click the main tab1 it is not storing the value of the maintab, when i click the subtabs of the maintab the value is storing. It is acting just opposite of what i required. Can you please let me know what made me wrong. Here is my VF page code. I mentioned in Red the changes i did in VF page to store a value.Appreciate your help.

 

 <apex:tab label="Maintab1" name="billName" id="Maintab1" onclick="callCon('maintab1');" style="background-color:white;" rendered="{!IF(lstHierarchyCustomerNameSearch.size>0,false,true)}" >

<apex:tabPanel switchType="client" selectedTab="name1" id="subTabPanel1" tabClass="activeTab" inactiveTabClass="inactiveTab">

<apex:tab label="Subscriber Billing" id="BTNtabTwo" style="background-color:white;">

<apex:pageBlockSection title="Subtab1" id="Subtab1">

<apex:outputText value="{!objCustomerAccount.Service_Type__c} {!objCustomerAccount.Ser_Type_Des__c}" label="Service Type"/>
  <apex:outputField value="{!objCustomerAccount.State_Tax_Code__c}"/>

<script>colorPageBlock(document.getElementById("{!$Component.Subscriberbillinginquiry}"), "{! strPageBlockSectionColorCode}");</script>

</apex:pageBlockSection>

</apex:tab>

<apex:tab label="subtab2" id="subtab2" style="background-color: white;" rendered="false"  >

 <apex:pageBlockSection title="subtab2Info." id="subtab2info">

 <apex:outputField value="{!objCustomerAccount.Credit_Rating__c}"/>

<apex:outputField value="{!objCustomerAccount.Last_Bill_Cycle__c}"/>

<script>colorPageBlock(document.getElementById("{!$Component.Creditandpriorbillinginfo}"), "{!strPageBlockSectionColorCode}");</script>

</apex:pageBlockSection>

</apex:tab>

<apex:tab label="Maintab2" name="name6" id="maintab2" onclick="callCon('maintab2');" style="background-color: white;"  rendered="{!IF(lstHierarchyCustomerNameSearch.size>0,false,true)}" >

As for maintab has 2 subtads this tab has also subtabs

<apex:actionFunction name="callCon" oncomplete="callCon1();">
                        <apex:param name="firstParam" value="" assignTo="{!Tabselected}"/>
                        </apex:actionFunction>
                        <apex:actionFunction name="callCon1" action="{!searchtab}"/>

Below is the Apexcode

public string Tabselected {get;set;}

public Tool_used__c tool;
 public List<Users_of_Tool__c>ulist;

 Public PageReference searchtab() {
  
    tool = new Tool_used__c();     //sreekanth  
    uList = new List<Users_of_tool__c>();
    
      if(Tabselected != null && Tabselected != '') {
    
        system.debug('###### '+Tabselected);
        tool.Search_by_WTN__c = Tabselected;
    }

return null;

}