+ Start a Discussion
bohemianguy100bohemianguy100 

tabPanel - tabs do not display correctly or work

I have a VF page with a standard controller and extension controller.  I'm using the tabPanel and tab controls, but the tabs do not display (only the text of the tab) and you can't click on the text of the tab to move from one tab to another.

 

Page:

 

<apex:page standardController="Lead" extensions="DispatcherLeadViewController" action="{!nullValue(redir.url, urlFor($Action.Lead.View, lead.id, null, true))}" showHeader="true" tabStyle="lead">
    <apex:tabPanel switchType="client" selectedTab="name1" id="theTabPanel">
        <apex:tab label="One" name="name1" id="tabOne">
        	<apex:outputField value="{!Lead.FirstName}" />
        </apex:tab>
        <apex:tab label="Two" name="name2" id="tabTwo">
        	<apex:outputField value="{!Lead.LastName}" />
        </apex:tab>
    </apex:tabPanel>
</apex:page>

 

controller:

 

public class DispatcherLeadViewController {
	
	private final ApexPages.StandardController controller;
	
	public DispatcherLeadViewController(ApexPages.StandardController controller) {
		this.controller = controller;
	}
	
	public PageReference getRedir() {
 
		Lead l = [Select id, recordtypeid From Lead Where Id = :ApexPages.currentPage().getParameters().get('id')];
 
		PageReference newPage;
 
		if (l.recordtypeid == '012400000005S9QAAU') {
			system.debug('We are here');
			newPage = Page.LeadViewTabbed;
			system.debug('************************* ' + newPage);
		} else {
			newPage = new PageReference('/' + l.id);
			newPage.getParameters().put('nooverride', '1');
		}
 
		newPage.getParameters().put('id', l.id);
		system.debug('********************** ' + newPage);
		return newPage.setRedirect(true);
 
	}
	
}

The problem appears to be related to the action attribute in the apex:page control.  If I remove that attribute, the tabs display fine, but then I am not able to display the visualforce page for a specific recordtype.  The visualforce page displays for every recordtype, which is not what I need to happen. 

 

Any help is appreciated.

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
sravusravu

If you are trying to initialize something using action attribute, then you are not suppose to use action attribute for initialization.

 

 Use expression language to reference an action method. For example, action="{!doAction}" references the doAction() method in the controller. If an action is not specified, the page loads as usual. If the action method returns null, the page simply refreshes. This method will be called before the page is rendered and allows you to optionally redirect the user to another page. This action should not be used for initialization.

All Answers

sravusravu

If you are trying to initialize something using action attribute, then you are not suppose to use action attribute for initialization.

 

 Use expression language to reference an action method. For example, action="{!doAction}" references the doAction() method in the controller. If an action is not specified, the page loads as usual. If the action method returns null, the page simply refreshes. This method will be called before the page is rendered and allows you to optionally redirect the user to another page. This action should not be used for initialization.

This was selected as the best answer
AparnaUpadhayayAparnaUpadhayay

Hi,

 

Did you resolved this issue?

 

Thanks