+ Start a Discussion
Amrin.Amrin. 

visualforce error please help!!

I am getting following error..


Error: t Compile Error: Constructor not defined: [selectOption].<Constructor>(String, String) at line 11 column 20

Please help

 

VFP :

 

<apex:page controller="t">
<apex:form >
  <apex:pageBlock >
  
      <apex:actionFunction name="RenderSection" action="{!RenderSec}"/>
  
      <apex:pageBlockSection>
          <apex:selectList multiselect="false" size="1" onChange="RenderSection() ;" value="{!SelectedVal}">
              <apex:selectOption itemLabel="--None--" itemValue=""/>
              <apex:selectOptions value="{!myList}"/>
          </apex:selectList>
      </apex:pageBlockSection>
  
      <apex:pageBlockSection rendered="{!showAccount}">
          <apex:outputLabel value="This Section will show account fields"/>
      </apex:pageBlockSection>
  
      <apex:pageBlockSection rendered="{!showContact}">
          <apex:outputLabel value="This section will show contact fields"/>
      </apex:pageBlockSection>
  
  </apex:pageBlock>
</apex:form>
</apex:page>

 Class :

public class t
{
    public List<SelectOption> myList {get; set;}
    public boolean showAccount {get; set;}
    public boolean showContact {get; set;}
    public String SelectedVal {get; set;}
    
    public t()
    {
        myList = new List<SelectOption>() ;
        myList.add(new SelectOption('Account' , 'Account')) ;
        myList.add(new SelectOption('Contact' , 'Contact')) ;
        
        showAccount = false ;
        showContact = false ;
        SelectedVal = '' ;
    }
    
    public PageReference RenderSec()
    {
        if(SelectedVal == 'Account')
        {
            showAccount = true ;
            showContact = false ;
        }
        if(SelectedVal == 'Contact')
        {
            showAccount = false ;
            showContact = true ;
        }
        return null ;
    }
}
Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

SelectOption definitely has a constructor that takes two strings.  Have you got a custom class named SelectOption by any chance.

All Answers

bob_buzzardbob_buzzard

SelectOption definitely has a constructor that takes two strings.  Have you got a custom class named SelectOption by any chance.

This was selected as the best answer
Amrin.Amrin.

Thanks bob_buzzard.... Yes, I deleted the class and it worked for me.

 

Thanks very much... :)