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
Shubham Kashyap 27Shubham Kashyap 27 

Unknown Property 'name' Error using Custom Controller

I am getting this error "Unknown property 'name' referenced in PageReference_Example_VF".

Can someone fix this, please?
Controller:
public class PageReference_Example {   
    public String selected {set;get;}
    public String name {set;get;}
    public PageReference callMe(){
        if(selected=='Housing'){
            PageReference p = new PageReference('/apex/HousingLoanPage');
            return p;
        }
        else{
            if(selected=='Personal'){
            PageReference p = new PageReference('/apex/PersonalLoanPage');
            return p;
        	}
        	else 
            	return null;
        }
    }
}
VF page
<apex:page controller="PageReference_Example">
    <apex:form>
    	<apex:page >
            <apex:pageBlock title="Home Page">
        		<apex:pageBlockSection >
            		<apex:pageBlockSectionItem>
                    	<apex:outputLabel value="Name"/>
                    	<apex:inputText value="{!name}"/>
                	</apex:pageBlockSectionItem>
            	</apex:pageBlockSection>
        	</apex:pageBlock>
        </apex:page>
    </apex:form>
</apex:page>
ManoharKumar0408ManoharKumar0408

Hi Shubham, 

You are geting this because you have two <apex:page > tag in you page. 

Thnaks,

Manohar

Raj VakatiRaj Vakati
Change your page like below 
 
<apex:page controller="PageReference_Example">
    <apex:form>
    	    <apex:pageBlock title="Home Page">
        		<apex:pageBlockSection >
            		<apex:pageBlockSectionItem>
                    	<apex:outputLabel value="Name"/>
                    	<apex:inputText value="{!name}"/>
                	</apex:pageBlockSectionItem>
            	</apex:pageBlockSection>
        	</apex:pageBlock>
      </apex:form>
</apex:page>

Use this controller
 
public class PageReference_Example {   
    public String selected {set;get;}
    public String name {set;get;}
public PageReference_Example (){
name ='';
}
    public PageReference callMe(){
        if(selected=='Housing'){
            PageReference p = new PageReference('/apex/HousingLoanPage');
            return p;
        }
        else{
            if(selected=='Personal'){
            PageReference p = new PageReference('/apex/PersonalLoanPage');
            return p;
        	}
        	else 
            	return null;
        }
    }
}

 
mukesh khandve786mukesh khandve786
<apex:page controller="testpage">
    <apex:form>
            <apex:pageBlock title="Home Page">
        		<apex:pageBlockSection >
            		<apex:pageBlockSectionItem>
                    	<apex:outputLabel value="Name"/>
                    	<apex:inputText value="{!Name}"/>
                	</apex:pageBlockSectionItem>
            	</apex:pageBlockSection>
        	</apex:pageBlock>
    </apex:form>
</apex:page>


plz use this


public class PageReference_Example {   
    public String selected {set;get;}
    public String name {set;get;}
    public PageReference callMe(){
        if(selected=='Housing'){
            PageReference p = new PageReference('/apex/HousingLoanPage');
            return p;
        }
        else{
            if(selected=='Personal'){
            PageReference p = new PageReference('/apex/PersonalLoanPage');
            return p;
        	}
        	else 
            	return null;
        }
    }
}

 
mukesh khandve786mukesh khandve786
i think problem is solved
Shubham Kashyap 27Shubham Kashyap 27

Thank you, guys could not figure that out.

Appreciate the support.