On running the following code in apex and visualforce respectively i am receiving following error:

Error: Unknown property 'Setter_Method.Oportunities'    
Quick Fix   Create Apex property 'Setter_Method.Oportunities'
Quick Fix   Create Apex method 'Setter_Method.getOportunities'

Apex Code:

public class Setter_Method {
    public String n; 
    List<opportunity> op;

    public String getSearch(){//to return the search query again
        return n;
    public List<Opportunity> getResult(){//to return the search results
        return op;
    public void setOportunities(String s){//to set the search from VF to apex 
    public PageReference display(){
        op =[SELECT Amount,Name,TotalOpportunityQuantity,probability from Opportunity WHERE name =:'n'];
        return null;

Visual Force code:

<apex:page controller="Setter_Method">
    <apex:form >
        <apex:pageBlock >
            <apex:inputText value="{!Oportunities}"/>
            <apex:commandButton action="{!display}" value="Search Name"/>
            <apex:pageBlockTable value="{!Result}" var="op">
                <apex:column value="{!op.name}"/>
                <apex:column value="{!op.Amount}"/>
                <apex:column value="{!op.TotalOpportunityQuantity}"/>
                <apex:column value="{!op.probability  }"/>


Please explain the logic of getter, setter and the attribute of <apex:inputText value"">

  • 3
    you definitely need to complete VF trailhead module, especially this one. All answers are explained here – Oleksandr Berehovskyi Mar 7 '18 at 12:29

You are getting this error because there is no getter method defined in controller for variable "Oportunities" and it is used in VF page:

<apex:inputText value="{!Oportunities}"/>

To overcome from this error you should create getter one of the following way:

Method 1:
By Updating following line

public  List<opportunity> op { get; set; }

Method 2: By adding following method

public List<Opportunity> getOportunities(){//to return the search results
    return op;

For more details you can go to Simple getter setter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.