Search code examples
salesforcecrmsalesforce-lightningsalesforce-service-cloudsalesforce-communities

visualforce page shows uknown method error


I have 2 wrapper class as below

public class Wr_Studennt{
    public string name{get;set;}
    public decimal salary{get;set;}
    public decimal exp{get;set;}
    public string technology{get;set;}
    
}

public class Wr_Address {
    public String city{get;set;}
    public string place{get;set;}
    public string pincode{get;set;}
    public String state{get;set;}
}

I have apex class as below

public class wr_Student_Address {
    public Wr_Studennt st{set;get;}
     public wr_student_Address()
    {
        st=new Wr_Studennt();
        
           }
    public void setstudent(string name,decimal salary,decimal exp,string technology)
    {
        st.name=name;
        st.salary=salary;
        st.exp=exp;
        st.technology=technology;
        
    }
    
    
}

My VF page isas below

<apex:page controller="wr_Student_Address">
    <apex:form>
   <apex:pageblock title="Student Details">
    <apex:pageBlockSection>
        
        <apex:outputLabel value="Name: "/>
                    <apex:inputText value="{!name}" />
        <apex:outputLabel value="Salary: "/>
                    <apex:inputText value="{!salary}" />
        <apex:outputLabel value="Exp: "/>
                    <apex:inputText value="{!exp}" />
        <apex:outputLabel value="Technology: "/>
                    <apex:inputText value="{!technology}" />
       
          <apex:commandButton value="setstudent" action="{! setstudent}" />
        
       </apex:pageBlockSection>
    </apex:pageblock>


</apex:form>

</apex:page>

It shows

Unknown property 'wr_Student_Address.name' error in line 0.

Please help me solving this issue. visualforce page shows

unknown method error


Solution

  • Your page controller wr_Student_Address has only 1 property: st. There's no field called name directly in this class.

    Try with merge field {!st.name}