You need to sign in to do that
Don't have an account?

Cannot call contacts in method
Hello team,
Can someone tells me what I am doing wrong with my code?
I am trying to call the contacts by clicking a button
Thanks in advance
Can someone tells me what I am doing wrong with my code?
I am trying to call the contacts by clicking a button
<apex:sectionHeader title="Contact Duplicates"/> <apex:pageBlockSection> <!-- SEARCH TAB --> <apex:actionRegion > <apex:outputPanel id="top" layout="block"> <!--[Styles CCS]--> <apex:outputLabel for="txtSearch"/> <apex:inputText id="txtSearch" html-placeholder="Search your account" value="{!searchStringCnt}" /> <span> <apex:commandButton id="btnGo" value="Search" action="{!SearchCnt}" rerender="searchResults"></apex:commandButton> </span> </apex:outputPanel> <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block"> <apex:pageBlock id="searchResults"> <apex:pageBlockTable value="{!resultsCnt}" var="c" id="tblResults"> <!--//[Checkbox]--> <apex:column headerValue="Selection"> <apex:inputCheckbox id="ckDuplicates"></apex:inputCheckbox> </apex:column> <apex:column> <apex:facet name="header"> <apex:outputPanel >Firstname</apex:outputPanel> </apex:facet> <apex:outputLink>{!Contact.FirstName}</apex:outputLink> </apex:column> <!--//Column Type--> <apex:column> <apex:facet name="header"> <apex:outputPanel >Lastname</apex:outputPanel> </apex:facet> <apex:outputLink>{!Contact.LastName}</apex:outputLink> </apex:column> <!--//Column Phone Number--> <apex:column > <apex:facet name="header"> <apex:outputPanel >Phone Number</apex:outputPanel> </apex:facet> <apex:outputLink>{!Contact.Phone}</apex:outputLink> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:actionRegion> </apex:pageBlockSection>Here is the method
///CONTACT DUPLICATE SERCHING //performs the keyword search public List<Account> resultsCnt {get;set;} //public Contact[] cnt {get;set;} public string searchStringCnt{get;set;} public PageReference searchCnt() { runSearchCnt(); return null; } // prepare the query and issue the search command private void runSearchCnt() { //prepare query string for complex serarches & prevent injections resultsCnt = performSearchCnt(searchStringCnt); } //run the search and return the records found. private List<Account> performSearchCnt(string searchStringCnt) { //String will make a callback of contacs //cnt = [SELECT id, firstName, lastName, phone FROM Contact]; String soql = 'SELECT id, firstName, lastName, phone FROM Contact'; if(searchStringCnt != '' && searchStringCnt != null) //soql = soql + ' where name LIKE \'%' + searchStringCnt +'%\''; //soql = soql + ' limit 25'; System.debug(soql); return database.query(soql); } // used by the visualforce page to send the link to the right dom element public string getFormTagCnt() { return System.currentPageReference().getParameters().get('frm'); } // used by the visualforce page to send the link to the right dom element for the text box public string getTextBoxCnt() { return System.currentPageReference().getParameters().get('txt'); }
Thanks in advance
What exactly are you trying to do ?
I see that you have created,
<apex:pageBlockTable value="{!resultsCnt}" var="c" id="tblResults">
And you havent used the 'C' variable anywhere to refer to your contacts in the VF page.
The Contact you used has no reference at all in the class.
In simple, try to do as below .
1.If you use a List<Contact> , try assigning this as the value for the dataTable and assign a variable to it.
2.Start using this variable to access each element from the list.
By this way you will be able to retrieve the values onto the page.
PLEASE SELECT THIS AS THE BEST ANSWER, IF YOU LIKE IT.
Thanks,
Rohit Alladi