0

In my application there is a VF page contains 5 tabs and each tabs performs different activities.There are 2 checkboxes present on the 2 different tabs. I have created a onclick JS button which uncheck the checkboxes if the checkbox is already checked. Now the problem that I am facing is when I unchecked it, it uncheck all the checkboxes of 2 tabs but I want to perform this activity for current tab only.

I have the following code in my VF which display the current tab name:

function displayPage() {
    var current = this.parentNode.getAttribute("data-current");
    if (current != null) {
                  document.getElementById("tabheader_" + current).removeAttribute("class");
        document.getElementById("tabpage_" + current).style.display="none";
    }
    var ident = this.id.split("_")[1];
            this.setAttribute("class","active");
    document.getElementById("tabpage_" + ident).style.display="block";
    this.parentNode.setAttribute("data-current",ident);
}

and I want to get the name/id of the tab in my apex class so that I can use in my IF condition. Can someone help me how can I get the current tab name of VF in apex class?

Note:When I click on a tab,i have to get the name of only those tab.

1
String tabId = ApexPages.currentPage().getParameters().get('sfdc.tabName');

This will get you tab Id of your current Visualforce Page Tab.

  • when I use the following syntax in my Apex class code then it gives me below error: A problem with the OnClick JavaScript for this button or link was encountered:{faultcode:'soapenv:Client', faultstring:'System.NullPointerException: Attempt to de-reference a null objectClass.OpportunityController.checkboxFalse: line 47, column 1', } – Dhananjay Patil Aug 17 '16 at 9:10
  • Is you Apex class controller for your Visualforce Page or just a normal class with static methods? – tugce Aug 17 '16 at 9:11
  • its a controller class actually which contains info about every tabs.As I am adding custom button to uncheck the checkbox where I am using Onclick JS,the logic behind the button is define in separate global class of webservice method where I have to get the current stage name where I clicked. – Dhananjay Patil Aug 17 '16 at 9:49
  • Well, I can only think of one thing about null reference error. That is your method (which you try to get tabId) is seperate from visualforce page. (webservice method.) I think you need to put your logic inside apex controller and instead of webservice method it should be inside public method. Or perhaps you can write a public method inside apex controller then this method can call your webservice method passing tabId as a parameter. – tugce Aug 17 '16 at 11:49
  • if i want to pass the value of 'ident' variable(Please find the above code)balue to the controller class.How can I pass it? I am very new in VF. when I click on the VF tab its value is stored in 'Ident' variable.I am trying to pass the variable value like this <apex:actionFunction action="{!StageNme}" name="displayPage"> <apex:param name="v" value="ident" assignTo="{!myCheckbox}" /> </apex:actionFunction> but I am getting null here.Can you please help me how can I pass the value to the controller class? – Dhananjay Patil Aug 19 '16 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.