-3

Apex code:

public with sharing  class CallCentre
{    
    public String search { get; set; }    
    public String searchquery { get; set; }    
    public list <Contact> con{get;set;}    
    public list<contact> contact{get;set;}    
    public string searchstring {get;set;}    

    public void search()
    {
        string query=
            'SELECT Name, Units_1__c, Email, Phone, tenant_street__c, tenant_city__c,
            ( SELECT   SVMXC__Problem_Description__c,Type_of_Order__c 
              FROM SVMXC__Service_Order__r) from 
              Contact WHERE Tenant_Street__c like \'%'+search+'%\' Limit 10';
        con = Database.query(query);
        system.debug('Con List'+con.size()+con);
    }

    public void clear()
    {
        con.clear();
    }

    public CallCentre()
    {

        Id  id=apexpages.currentpage().getparameters().get('ID');
        contact = [SELECT Name, Units_1__c, Email , Phone, tenant_street__c,   
        tenant_city__c,(SELECT SVMXC__Problem_Description__c,Type_of_Order__c from SVMXC__Service_Order__r) from Contact WHERE Id= :id];
        System.debug(' ***** '+ contact); 
    }
}

VF code:

<apex:page controller="CallCentre" sidebar="false" extensions="mycontactcontroller" >
<apex:form >
<apex:pageBlock title="Contact Service Department">
<apex:OutputText value=" Address : "/>
<apex:inputText label="Address" value="{!search}"/>
<apex:commandButton value="search" action="{!Search}" rerender="pbt"/>
</apex:pageBlock>
<apex:pageBlock title="Search Results" >
<apex:pageBlockTable id="pbt" value="{! con}" var="c">
<apex:column value="{!c.Name}"/>
<apex:column value="{!c.Units_1__c}"/>
<apex:column value="{!c.Email}"/>
<apex:column value="{!c.phone}"/>
<apex:column value="{!c.tenant_street__c}"/>
<apex:outputLink value="/apex/displaycontactrecord?id={!c.id}">{!c.name} </apex:outputLink>
</apex:column>
glls
  • 20,137
  • 19
  • 46
  • 82
Rajesh
  • 1
  • 4
  • 4
    Where exactly is the failure? There is no selection-related code in the class you are sharing. Please edit your question to include the area(s) of code that aren't working, and what you've tried to accomplish the objective. – David Reed Feb 09 '18 at 03:16
  • Thank you David Reed for your response. The result of the query is displayed in VF page. It is working perfect, I am using output link in VF to display the a specific record that user has selected from the result of SOQL query using apexpages.currentpage().getparameters().get('ID') . new page is opening but the query what i am selecting is not displaying. I am new to VF pages, – Rajesh Feb 09 '18 at 04:16

1 Answers1

2

From the documentation on the Map class:

Map keys of type String are case-sensitive. Two keys that differ only by the case are considered unique and have corresponding distinct Map entries. Subsequently, the Map methods, including put, get, containsKey, and remove treat these keys as distinct.

You are using 'id' to pass your parameter in the command link and 'ID' to pull it, so you get a null value.

David Reed
  • 92,733
  • 13
  • 84
  • 157