Am using <apex:tabPanel switchType="client" selectedTab="Survey" > and have 2 tabs in them as:

<apex:tab label="Survey" name="Survey" id="Survey"></apex:tab>
<apex:tab label="Visit Types Mapping" name="VisitMapping" id="VisitMapping"></apex:tab>

Now, I have a save button in the "Visit Types Mapping" tab .Whenever I click on save the the page is getting redirected to the default selected tab that is "Survey". My functionality demands to stay on the same tab i.e, "VisitMapping" tab.

  • Did you try to add onclick="return false;" on your button to prevend the redirection ?
    – SF_user
    Sep 26 '14 at 10:49

Change switch type to server:

<apex:tabPanel switchType="server" selectedTab="Survey" >

Also on "Save" button click, rerender the tab panel. It will prevent reload or redirection of page.

Another approach (set controller variable):

<apex:tabPanel switchType="server" selectedTab="{!selectedTab}" >

Yet another approach is to NOT re-render the apex:tabPanel by e.g. only re-rendering the save button:

 <apex:commandButton id="me" value="Save" action="{!save}" rerender="me"/>

The switchType="client" can then remain; depending on what is in your tabs switchType="server" can be sluggish.

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.