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
lane_cwelane_cwe 

Dependent Picklist Does Not Work when showHeader is False

I created a VF page (23.0 API version) with 2 dependent picklists. If showHeader property is false in apex:page, the dependent picklist value is not set in controller when Search button is clicked. However if showHeader property is true, I do not have this problem. Does anyone come across this problem before? Any suggestion or alternative methods? I prefer not to display the Salesforce header in the page. I have simplified the code as below:-

 

<apex:page controller="testController" sidebar="false" showHeader="false" >
<apex:form >
<apex:actionFunction name="setType" rerender="type"/>
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockSection columns="1" title="Search Option">
<apex:pageBlockSectionItem >
	    <apex:outputLabel value="Product" />
		<apex:selectList size="1" value="{!productFilter}" onchange="setType();">
			<apex:selectOption itemLabel="-All-" itemValue="" />
            <apex:selectOptions value="{!productList}"/>
        </apex:selectList>
 </apex:pageBlockSectionItem>
 <apex:pageBlockSectionItem >
        <apex:outputLabel value="Type" />
        <apex:selectList size="1" value="{!typeFilter}" id="type">
        	<apex:selectOption itemLabel="-All-" itemValue="" />
            <apex:selectOptions value="{!typeList}"/>
       	</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

<apex:pageBlockButtons location="bottom">
	<apex:commandButton value="Search" action="{!doSearch}" rerender="valueInController"/>     
</apex:pageBlockButtons>	
</apex:pageBlock>

<apex:pageBlock id="valueInController">
<apex:pageBlockSection columns="1">
<apex:outputText value="Product:{!productFilter}"/>
<apex:outputText value="Type:{!typeFilter}"/>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</apex:page>

 

public class testController {
	public String productFilter {get;set;}
  	public String typeFilter {get;set;}
  	
  	private static Map<String,List<String>> dependentMap = new Map<String,List<String>>();
	static {
		dependentMap.put('Alphabet',new List<String>{'A','B','C'});
		dependentMap.put('Number',new List<String>{'1','2','3','4','5'});
		dependentMap.put('Symbol',new List<String>{'%','$','#'});
	}
	
  	public testController() {	
  	} 

    
    public List<SelectOption> getProductList() {
    	List<SelectOption> productList = new List<SelectOption>();
    	productList.add(new SelectOption('Alphabet','Alphabet'));
    	productList.add(new SelectOption('Number','Number'));
    	productList.add(new SelectOption('Symbol','Symbol'));
  		return productList;
  	}
  	
  	public List<SelectOption> getTypeList(){
    	List<SelectOption> typeList = new List<SelectOption>();
    	if (dependentMap.containsKey(productFilter)){
	  		for (String option : dependentMap.get(productFilter)){
	  			typeList.add(new SelectOption(option, option));
	  		}
    	}
    	return typeList;
    }
    
    public PageReference doSearch(){
    	return null;
    }
}

 



bob_buzzardbob_buzzard

Setting showHeader to false also stops including the standardStyleSheets, which may be having an impact.

 

Try adding the following attribute to your apex:page tag - standardStyleSheets="true"

lane_cwelane_cwe

Tried but it didn't work in IE9