+ Start a Discussion
Santi Ram RaiSanti Ram Rai 

StandardController ERROR.

Hi everybody,

I want display the data from standardController, but i have this error "Unknown property 'Employee__cStandardController.employees'"

Screen Shoot:
User-added image

Visualforce page:
<apex:page standardController="Employee__c" extensions="loadPageProController" showHeader="false"  sidebar="false"  action="{!runSearch}" >
    <apex:form >
      <apex:pageMessages id="errors"/>
        <apex:pageBlock title="All Projects Detail" mode="edit">
            <table width="100%" border="0">
                <tr>
                    <td width="200" valign="top">
                        <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                        <script type="text/javascript">
                          function doSearch() {
                            searchServer(
                              document.getElementById("Name").value
                       		);
	                        }
                        </script>
                            <!--Search Function-picklist-->
                            <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                                <apex:param name="Name" value=""/>
      						</apex:actionFunction>
                            <table cellpadding="2" cellspacing="2">
                              <tr>
                               <td style="font-weight:bold;">Project Name<br/>
                                <input type="text" id="Name" onkeyup="doSearch();"/>
                                </td>
                              </tr>
                              </table>
      				</apex:pageBlock>
    			</td>
    		<td valign="top">
            <apex:pageBlock mode="edit" id="results">
                <apex:pageBlockTable value="{!employees}" var="employee">
                <apex:column headerValue="Action" style="float:right;width:90%"  > 
                    <apex:outputLink style="Color:blue" value="{!URLFOR($Action.Employee__c.Edit,employee.Id)}"> Edit </apex:outputLink>          
                </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Employee Name" action="{!toggleSort}" rerender="results,debug">
                                <apex:param name="sortField" value="Employee Name" assignTo="{!sortField}"/>
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!employees.Name}"/>
                    </apex:column>
               	 </apex:pageBlockTable>
            </apex:pageBlock>
         </td>
  		</tr>
  </table>
  </apex:pageBlock>
  </apex:form>
</apex:page>

Apex Class:
public class loadPageEmpController {
     public loadPageEmpController (ApexPages.StandardController controller) {
    }
    
    //The soql without the order and limit
    private String soql {get;set;}
  
  	//The collection of contacts to display
    public List<Employee__c>employees{get;set;}

   //The current sort direction. defaults to asc
    public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;}
    set;
    }

  	//The current field to sort by. defaults to  name
    public String sortField {
    get{ if (sortField == null) {sortField = 'Name'; } return sortField;}
    set;
    }

  	//Format the soql for display on the visualforce page
    public String debugSoql {
        get { return soql + ' order by ' + sortField + ' ' + sortDir; }
        set;
    }

  	//Init the controller and display some sample data when the page loads
  	public loadPageEmpController (){
 	     soql = 'select Name, account_has_many_emp__c, Last_Name__c,Phone__c,Date_Of_Birth__c from Employee__c where Name !=null';
 	     runQuery();
 	 }

  	//Toggles the sorting of query from asc<-->desc
    public void toggleSort() {
        // simply toggle the direction
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
        // run the query again
        runQuery();
    }

  	//Runs the actual query
    public void runQuery(){
        try {
          employees= Database.query(soql + ' order by ' + sortField + ' ' + sortDir);
        }catch (Exception e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
        }
    }
    
  	//Search by Project Types.
  	//Runs the search with parameters passed via Javascript
    public PageReference doSearch() {
        Id accId= Apexpages.currentPage().getParameters().get('Id');
        String Name= Apexpages.currentPage().getParameters().get('Name');
     
 	    soql = 'select Name, account_has_many_emp__c, Last_Name__c,Phone__c,Date_Of_Birth__c from Employee__c where Name !=null';
        if (Name!= null &&!Name.equals(''))
        soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';  
        
        // run the query again
        runQuery();
        return null;
    }
}


 
Best Answer chosen by Santi Ram Rai
pconpcon
I beleive your issue is that you are using emp instead of employee
 
<apex:outputField value="{!employee.Name}"/>

 

All Answers

pconpcon
The problem is that you are not using the controller you have displayed below.  You are using loadPageProController and you have loadPageEmpController
Santi Ram RaiSanti Ram Rai
I have changed, and now i have this error "Could not resolve the entity from <apex:outputField> value binding '{!emp.Name}'.  <apex:outputField> can only be used with SObjects, or objects that are Visualforce field component resolvable."

Visualforce page:
<apex:page standardController="Employees__c" extensions="newoneapex" showHeader="false"  sidebar="false"  action="{!runSearch}" >
    <apex:form >
      <apex:pageMessages id="errors"/>
        <apex:pageBlock title="All Projects Detail" mode="edit">
            <table width="100%" border="0">
                <tr>
                    <td width="200" valign="top">
                        <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                        <script type="text/javascript">
                          function doSearch() {
                            searchServer(
                              document.getElementById("Name").value
                       		);
	                        }
                        </script>
                            <!--Search Function-picklist-->
                            <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                                <apex:param name="Name" value=""/>
      						</apex:actionFunction>
                            <table cellpadding="2" cellspacing="2">
                              <tr>
                               <td style="font-weight:bold;">Project Name<br/>
                                <input type="text" id="Name" onkeyup="doSearch();"/>
                                </td>
                              </tr>
                              </table>
      				</apex:pageBlock>
    			</td>
    		<td valign="top">
            <apex:pageBlock mode="edit" id="results">
                <apex:pageBlockTable value="{!emp}" var="employee">
                <apex:column headerValue="Action" style="float:right;width:90%"  > 
                    <apex:outputLink style="Color:blue" value="{!URLFOR($Action.Employees__c.Edit,employee.Id)}"> Edit </apex:outputLink>          
                </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Employee Name" action="{!toggleSort}" rerender="results,debug">
                                <apex:param name="sortField" value="Employee Name" assignTo="{!sortField}"/>
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!emp.Name}"/>
                    </apex:column>
               	 </apex:pageBlockTable>
            </apex:pageBlock>
         </td>
  		</tr>
  </table>
  </apex:pageBlock>
  </apex:form>
</apex:page>

Apex Class:
public with sharing class newoneapex {
        public newoneapex (ApexPages.StandardController controller) {
    }
    
    //The soql without the order and limit
    private String soql {get;set;}
  
  	//The collection of contacts to display
    public List<Employees__c>emp{get;set;}

   //The current sort direction. defaults to asc
    public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;}
    set;
    }

  	//The current field to sort by. defaults to  name
    public String sortField {
    get{ if (sortField == null) {sortField = 'Name'; } return sortField;}
    set;
    }

  	//Format the soql for display on the visualforce page
    public String debugSoql {
        get { return soql + ' order by ' + sortField + ' ' + sortDir; }
        set;
    }

  	//Init the controller and display some sample data when the page loads
  	public newoneapex (){
 	     soql = 'select Name, account_has_many_emp__c, Last_Name__c,Phone__c,Date_Of_Birth__c from Employee__c where Name !=null';
 	     runQuery();
 	 }

  	//Toggles the sorting of query from asc<-->desc
    public void toggleSort() {
        // simply toggle the direction
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
        // run the query again
        runQuery();
    }

  	//Runs the actual query
    public void runQuery(){
        try {
          emp= Database.query(soql + ' order by ' + sortField + ' ' + sortDir);
        }catch (Exception e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
        }
    }
    
  	//Search by Project Types.
  	//Runs the search with parameters passed via Javascript
    public PageReference runSearch() {
        Id accId= Apexpages.currentPage().getParameters().get('Id');
        String Name= Apexpages.currentPage().getParameters().get('Name');
     
 	    soql = 'select Name, account_has_many_emp__c, Last_Name__c,Phone__c,Date_Of_Birth__c from Employee__c where Name !=null';
        if (Name!= null &&!Name.equals(''))
        soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';  
        
        // run the query again
        runQuery();
        return null;
    }

}


 
pconpcon
I beleive your issue is that you are using emp instead of employee
 
<apex:outputField value="{!employee.Name}"/>

 
This was selected as the best answer