You need to sign in to do that
Don't have an account?
Nagaraju P 5
Unknown property error on VF page with custom controller
I'll post the VF page and the controller below. Here's the error message I'm getting when trying to save my page:
Error: Unknown property 'String.Name'
VF Page code:
<apex:page controller="TestPagination">
<apex:form >
<apex:pageBlock id="pb">
<apex:pageBlockTable value="{!Lead}" var="a">
<apex:column value="{!a.Name}}"/>
<apex:column value="{!a.company}}"/>
<apex:column value="{!a.Email}}"/>
<apex:column value="{!a.Lead status}"/>
<apex:column value="{!a.Lead source}"/>
</apex:pageBlockTable>
<apex:panelGrid columns="7">
<apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
<apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
<apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
<apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
<apex:outputText >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText>
<apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
<apex:outputPanel style="color:#4AA02C;font-weight:bold">
<apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
</apex:outputPanel>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller code:
public with sharing class TestPagination {
public String Lead { get; set; }
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
public ApexPages.StandardSetController setCon1 {
get{
if(setCon1 == null){
size = 10;
string queryString = 'Select Name, Company, Email, Lead Status, Lead Source from Lead order by Name';
setCon1 = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon1.setPageSize(size);
noOfRecords = setCon1.getResultSize();
}
return setCon1;
}set;
}
Public List<Lead> getLead(){
List<Lead> accList = new List<Lead>();
for(Lead a : (List<Lead>)setCon1.getRecords())
accList.add(a);
return accList;
}
public pageReference refresh() {
setCon1 = null;
getLead();
setCon1.setPageNumber(1);
return null;
}
public Boolean hasNext {
get {
return setCon1.getHasNext();
}
set;
}
public Boolean hasPrevious {
get {
return setCon1.getHasPrevious();
}
set;
}
public Integer pageNumber {
get {
return setCon1.getPageNumber();
}
set;
}
public void first() {
setCon1.first();
}
public void last() {
setCon1.last();
}
public void previous() {
setCon1.previous();
}
public void next() {
setCon1.next();
}
}
I am new to apex. Please help me to resolve this error. Thanks in advance
Error: Unknown property 'String.Name'
VF Page code:
<apex:page controller="TestPagination">
<apex:form >
<apex:pageBlock id="pb">
<apex:pageBlockTable value="{!Lead}" var="a">
<apex:column value="{!a.Name}}"/>
<apex:column value="{!a.company}}"/>
<apex:column value="{!a.Email}}"/>
<apex:column value="{!a.Lead status}"/>
<apex:column value="{!a.Lead source}"/>
</apex:pageBlockTable>
<apex:panelGrid columns="7">
<apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/>
<apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/>
<apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!hasNext}" title="Next Page"/>
<apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!hasNext}" title="Last Page"/>
<apex:outputText >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText>
<apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
<apex:outputPanel style="color:#4AA02C;font-weight:bold">
<apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
</apex:outputPanel>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller code:
public with sharing class TestPagination {
public String Lead { get; set; }
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
public ApexPages.StandardSetController setCon1 {
get{
if(setCon1 == null){
size = 10;
string queryString = 'Select Name, Company, Email, Lead Status, Lead Source from Lead order by Name';
setCon1 = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
setCon1.setPageSize(size);
noOfRecords = setCon1.getResultSize();
}
return setCon1;
}set;
}
Public List<Lead> getLead(){
List<Lead> accList = new List<Lead>();
for(Lead a : (List<Lead>)setCon1.getRecords())
accList.add(a);
return accList;
}
public pageReference refresh() {
setCon1 = null;
getLead();
setCon1.setPageNumber(1);
return null;
}
public Boolean hasNext {
get {
return setCon1.getHasNext();
}
set;
}
public Boolean hasPrevious {
get {
return setCon1.getHasPrevious();
}
set;
}
public Integer pageNumber {
get {
return setCon1.getPageNumber();
}
set;
}
public void first() {
setCon1.first();
}
public void last() {
setCon1.last();
}
public void previous() {
setCon1.previous();
}
public void next() {
setCon1.next();
}
}
I am new to apex. Please help me to resolve this error. Thanks in advance
Try with below code. Use 'LeadList' or other name for property as 'Lead' is a standard object. so there might be conflict.
Let us know if it helps you.
All Answers
Try with below code. Use 'LeadList' or other name for property as 'Lead' is a standard object. so there might be conflict.
Let us know if it helps you.
Please mark it as solved ,so others can get help form it in case of same issue.