• Dhiraj Gupta 1
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hi Team,

I am calling apex class from constrctor but while debugging i am getting below error and cursor is not going inside setCallback method. It seems it is not calling apex class. Below is code:

Error is:
his page has an error. You might just need to refresh it. Action failed: c:BeerExplorer$controller$handleCompEvents [Invalid key search] Failing descriptor: {c:BeerExplorer$controller$handleCompEvents}

Controller code:

({
    handleCompEvents : function(component, event, helper) {
        var searchParam=event.getParam('searchText');
        var action=component.get('search');
        action.setParams({
            txtSearch:searchParam
        });
        
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state=='SUCCESS')
            {
                var responseValue=response.getReturnValue();
                console.log('responseValue',responseValue);
            }
        })
    }
})

Apex Class: 
public class BeerExplorer {

    @AuraEnabled
    public static List<Beer__c> search(string txtSearch)
    {
        string likeParam='%' + txtSearch + '%';
        string query= 'select Id, Name, From Beer__c where Name Like: likeParam ';
        List<Beer__c> beerList=Database.query(query);
        return beerList;
    }
    
}
 
Hi Team,

When we type in search box then doSearch method of JS should be called but it's not happening.

Below is code:

Component code:

<aura:component >
     <aura:registerEvent name="BeerEvent" type="c:SearchEvents"/>
    <div class="slds-p-around_small">
      <lightning:input
        name="inline-search-input"
        label="Beer Search"
        type="search"
        variant="label-hidden"
       aura:id="searachInput"
       onChange="{!c.doSearch}"
    />
    </div>
</aura:component>

JS Code:
({
    doSearch : function(component, event, helper) {
        var componentEvents=component.getEvents('BeerEvent');
        var searchParam=componenet.find('searachInput').get('v.value');
        alert(searchParam);
        componentEvent.setParams({
            searchText:searchParam       
        });
        component.fire();
    }
})
Hi Team,

I am calling apex class from constrctor but while debugging i am getting below error and cursor is not going inside setCallback method. It seems it is not calling apex class. Below is code:

Error is:
his page has an error. You might just need to refresh it. Action failed: c:BeerExplorer$controller$handleCompEvents [Invalid key search] Failing descriptor: {c:BeerExplorer$controller$handleCompEvents}

Controller code:

({
    handleCompEvents : function(component, event, helper) {
        var searchParam=event.getParam('searchText');
        var action=component.get('search');
        action.setParams({
            txtSearch:searchParam
        });
        
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state=='SUCCESS')
            {
                var responseValue=response.getReturnValue();
                console.log('responseValue',responseValue);
            }
        })
    }
})

Apex Class: 
public class BeerExplorer {

    @AuraEnabled
    public static List<Beer__c> search(string txtSearch)
    {
        string likeParam='%' + txtSearch + '%';
        string query= 'select Id, Name, From Beer__c where Name Like: likeParam ';
        List<Beer__c> beerList=Database.query(query);
        return beerList;
    }
    
}
 
Hi Team,

When we type in search box then doSearch method of JS should be called but it's not happening.

Below is code:

Component code:

<aura:component >
     <aura:registerEvent name="BeerEvent" type="c:SearchEvents"/>
    <div class="slds-p-around_small">
      <lightning:input
        name="inline-search-input"
        label="Beer Search"
        type="search"
        variant="label-hidden"
       aura:id="searachInput"
       onChange="{!c.doSearch}"
    />
    </div>
</aura:component>

JS Code:
({
    doSearch : function(component, event, helper) {
        var componentEvents=component.getEvents('BeerEvent');
        var searchParam=componenet.find('searachInput').get('v.value');
        alert(searchParam);
        componentEvent.setParams({
            searchText:searchParam       
        });
        component.fire();
    }
})