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
Jose Boveda 6Jose Boveda 6 

Unknown Property error with Custom Controller

I have a custom controller and a Visualforce page and every time I try to save the page, I get the error:
Error: Unknown property 'TMCR_AssocInventorController.inventors'
I can't seem to figure it out. My problem seems to be identical to another entry: https://developer.salesforce.com/forums/ForumsMain?id=906F000000096uoIAA however it's been of no use as I still get the error.

Any help is much appreciated!

Here's the Visualforce page:
<apex:page Controller="AssocInventorController" tabstyle="Case">
    <apex:pageBlock title="Associated Inventors" >
    <apex:pageBlockTable value="{!inventors}" var="ai">
        <apex:column headerValue="Id"><a href="/{!ai.Id}">{!ai.Id}</a></apex:column>
        <apex:column headerValue="Inventor"><a href="/{!ai.Inventor__c}">{!ai.Inventor__c}</a></apex:column>
        <apex:column headerValue="Inventor Type">{!ai.Inventor_Type__c}</apex:column>
        <apex:column headerValue="Role">{!ai.Role__c}</apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>
And here's the Controller:
public with sharing class AssocInventorController {
	public List<Associated_Inventor__c> Inventors {get{
		if (Inventors = null){
			Inventors = getInventors();
		}
	}private set;}
	public List<Associated_Inventor__c> getInventors() {
		return [
			select id, Inventor__c, Inventor_Type__c, Role__c 
			from Associated_Inventor__c 
			where SF_ID__c = :System.currentPageReference().getParameters().get('id')
			group by Inventor__c
			order by Case_Filing__r.Name asc
		];
	}
}

 
Best Answer chosen by Jose Boveda 6
Amit Chaudhary 8Amit Chaudhary 8
Please try below code :-

Page :-
<apex:page Controller="AssocInventorController" tabstyle="Case">
    <apex:pageBlock title="Associated Inventors" >
    <apex:pageBlockTable value="{!inventors}" var="ai">
        <apex:column headerValue="Id"><a href="/{!ai.Id}">{!ai.Id}</a></apex:column>
        <apex:column headerValue="Inventor"><a href="/{!ai.Inventor__c}">{!ai.Inventor__c}</a></apex:column>
        <apex:column headerValue="Inventor Type">{!ai.Inventor_Type__c}</apex:column>
        <apex:column headerValue="Role">{!ai.Role__c}</apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Class :-
public with sharing class AssocInventorController 
{
	public List<Associated_Inventor__c> Inventors {
	get{
		if (Inventors == null){
			Inventors = getInventors();
		}
		return Inventors;
	}
	private set;
	}
	
	public List<Associated_Inventor__c> getInventors() 
	{
		return [
			select id, Inventor__c, Inventor_Type__c, Role__c 
			from Associated_Inventor__c 
			where SF_ID__c = :System.currentPageReference().getParameters().get('id')
			group by Inventor__c
			order by Case_Filing__r.Name asc
		];
	}
}


Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
 

All Answers

surasura
below code should work 
public with sharing class AssocInventorController {
	public List<Associated_Inventor__c> Inventors {
	  get{
	     
		 
		 if (Inventors==null)
		 {
			Inventors = getInventors();
		 }
		 return Inventors;
	    }private set;}
	public List<Associated_Inventor__c> getInventors() {
		return [
			select id, Inventor__c, Inventor_Type__c, Role__c 
			from Associated_Inventor__c 
			where SF_ID__c = :System.currentPageReference().getParameters().get('id')
			group by Inventor__c
			order by Case_Filing__r.Name asc
		];
	}
}

 
Amit Chaudhary 8Amit Chaudhary 8
Please try below code :-

Page :-
<apex:page Controller="AssocInventorController" tabstyle="Case">
    <apex:pageBlock title="Associated Inventors" >
    <apex:pageBlockTable value="{!inventors}" var="ai">
        <apex:column headerValue="Id"><a href="/{!ai.Id}">{!ai.Id}</a></apex:column>
        <apex:column headerValue="Inventor"><a href="/{!ai.Inventor__c}">{!ai.Inventor__c}</a></apex:column>
        <apex:column headerValue="Inventor Type">{!ai.Inventor_Type__c}</apex:column>
        <apex:column headerValue="Role">{!ai.Role__c}</apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

Class :-
public with sharing class AssocInventorController 
{
	public List<Associated_Inventor__c> Inventors {
	get{
		if (Inventors == null){
			Inventors = getInventors();
		}
		return Inventors;
	}
	private set;
	}
	
	public List<Associated_Inventor__c> getInventors() 
	{
		return [
			select id, Inventor__c, Inventor_Type__c, Role__c 
			from Associated_Inventor__c 
			where SF_ID__c = :System.currentPageReference().getParameters().get('id')
			group by Inventor__c
			order by Case_Filing__r.Name asc
		];
	}
}


Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help
 
This was selected as the best answer