function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SANJUKTA BASAK 3SANJUKTA BASAK 3 

VisualforcePage Search button not functioning

Hi,
I have developed a search page that would fetch results according to the values selected by the user.The results should be displayed upon clicking the Search button.But this button doesn't seem to be working as expected. Below is the apex controller and vf page for the same.

Controller : 
public without sharing class BadgeControllerExtension
{
     
    private String soql {get;set;}
    // the collection of badges to display
    public List<Event_Attendee_Badge__c> badges {get;set;}
    public List<Event_Attendee_Badge__c> lstEvents= new List<Event_Attendee_Badge__c>();
    public List<Event__c> lstEvt = new List<Event__c>();
    public List<Attendee__c> lstAtt = new List<Attendee__c>();
    public Set<ID> evtIds = new Set<ID>();
    public String evtName;
    public String selectLocation{get;set;}
    /*public BadgesController(){
            selectLocation = '';
    }*/
    
    //parameters
    public String Event{get;set;}
    public String Location{get;set;}
    public String Attendee{get;set;}
    public List<Event__c> lstEventBadge{get;set;}
    
 
  public List<SelectOption> getEventsList()
    {
        lstEvents = [Select Event__c,Date__c,Location__c From Event_Attendee_Badge__c];
        List<SelectOption> eventBadgeList = new List<SelectOption>();
        eventBadgeList.add(new SelectOption( ' ' ,'---Select---'));
        for(Event_Attendee_Badge__c evt : lstEvents)
        {
            evtIds.add(evt.Event__c);
        }
        lstEvt = [Select Name From Event__c where ID IN:evtIds];
        for(Event__c evt1 : lstEvt)
        {
            eventBadgeList.add(new SelectOption(evt1.Name, evt1.Name));
        }
        return eventBadgeList;
    }
    public List<SelectOption> getLocationsList()
    {
        lstEvents = [Select Event__c,Date__c,Location__c From Event_Attendee_Badge__c];
        List<SelectOption> eventBadgeList = new List<SelectOption>();
        eventBadgeList.add(new SelectOption( ' ' ,'---Select---'));
        for(Event_Attendee_Badge__c evt : lstEvents)
        {
            eventBadgeList.add(new SelectOption(evt.Location__c, evt.Location__c));
        }
        return eventBadgeList;
    }
    public List<SelectOption> getAttendeesList()
    {
        lstEvents = [Select Event__c,Date__c,Location__c,Attendee__c From Event_Attendee_Badge__c];
        List<SelectOption> eventBadgeList = new List<SelectOption>();
        eventBadgeList.add(new SelectOption( ' ' ,'---Select---'));
        for(Event_Attendee_Badge__c evt : lstEvents)
        {
            evtIds.add(evt.Attendee__c);
        }
        lstAtt = [Select Name From Attendee__c where ID IN:evtIds];
        for(Attendee__c att : lstAtt)
        {
            eventBadgeList.add(new SelectOption(att.Name, att.Name));
        }
        return eventBadgeList;
    }
    public void echoVal()
    {
        Event =  Apexpages.currentPage().getParameters().get('firstParam');
        System.debug('Event Name ='+Event);
        Location = Apexpages.currentPage().getParameters().get('secondParam');
        System.debug('Location Name ='+Location);
        Attendee = Apexpages.currentPage().getParameters().get('thirdParam');
        System.debug('Attendee Name ='+Attendee );
        runSearch();
    }

    // runs the search with parameters passed via Javascript
    public void runSearch() {
	String searchEvent = system.label.Percentage_Value +Event+ system.label.Percentage_Value;
    String searchLocation =  system.label.Percentage_Value +Location+ system.label.Percentage_Value;
    String searchAttendee = system.label.Percentage_Value +Attendee+ system.label.Percentage_Value; 
    lstEventBadge =[select Name,Date__c,Location__c From Event__c where Name LIKE : searchEvent];
    System.debug('List is='+lstEventBadge);    
        if(lstEventBadge.isEmpty()){           
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,system.label.SearchPage_ErrorMessage));
        }
       
    }
}

VFPage:
<apex:page controller="BadgeControllerExtension" >
    <apex:form >
        <apex:pageBlock title="{!$Label.AccountsView}" id="PageBlock">
            <apex:pageBlockButtons >
                <apex:commandButton value="Search" onclick="callActionMethod()" action="{!runSearch}" status="showStatus" reRender="tablePageBlocksectionSFDC" id="sfdcLookup" tabindex="8"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="2" title="Choose Event" id="theEventPageBlockSection" collapsible="false" >
                <apex:outputLabel value="Event" />
                    <apex:outputPanel layout="block" id="Event" styleClass="requiredInput">
                        <div class="requiredBlock"></div>-
                    <apex:selectList size="1">
                        <apex:selectOptions value="{!EventsList}" id="ev"></apex:selectOptions>
                    </apex:selectList>
                    </apex:outputPanel>
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="2" title="Choose Location" id="theLocationPageBlockSection" collapsible="false" >
                <apex:outputLabel value="Location" />
                    <apex:outputPanel layout="block" id="Location" styleClass="requiredInput">
                        <div class="requiredBlock"></div>-
                    <apex:selectList size="1">
                        <apex:selectOptions value="{!LocationsList}" id="lo"></apex:selectOptions>
                    </apex:selectList>
                    </apex:outputPanel>
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="2" title="Choose Attendee" id="thePageBlockSection" collapsible="false" >
                <apex:outputLabel value="Attendee" />
                    <apex:outputPanel layout="block" id="Attendee" styleClass="requiredInput">
                        <div class="requiredBlock"></div>-
                    <apex:selectList size="1">
                        <apex:selectOptions value="{!AttendeesList}" id="att"></apex:selectOptions>
                    </apex:selectList>
                    </apex:outputPanel>
            </apex:pageBlockSection>
            
            <!--<span class="pointer" onclick="callActionMethod()"> Click </span>-->
            <apex:actionFunction name="echo" action="{!echoVal}" reRender="resultPanel" status="myStatus">
                <apex:param name="firstParam"  value="" />
                    <apex:param name="secondParam"  value="" />
                            <apex:param name="thirdParam"  value="" />
            </apex:actionFunction>
            
            <script type="text/javascript">
            function callActionMethod()
            {
                var evtVal = document.getElementById("{!$Component.frm.ev}").value;
                var locVal = document.getElementById("{!$Component.frm.lo}").value;
                var attVal = document.getElementById("{!$Component.frm.att}").value; 
                /*Below Method is generated by "apex:actionFunction" which will call Apex Method "echoVal" */
                echo(evtVal,locVal,attVal);
            }
            </script>
            
            <apex:pageBlockSection collapsible="false" title="Following Badges found!" id="tablePageBlocksectionSFDC" columns="1" rendered="{!IF(AND(NOT(ISBLANK(lstEventBadge)),lstEventBadge.size>0),'Yes','No')}">
                <apex:pageBlockTable value="{!lstEventBadge}" var="recVar"  columnsWidth="3%,18%,10%,10%,10%" rendered="{!if(lstEventBadge.size <> null,true,false)}">                       
                    <apex:column headerValue="Event Name">
                        <apex:outputlink value="#" onclick="window.open('/{!recVar.Id}','_blank');">{!recVar.Name}</apex:outputlink>
                    </apex:column>
                        <apex:column value="{!recVar.Date__c}" headerValue="Event Date" />
                            <apex:column value="{!recVar.Location__c}" headerValue="Event Location" />
                </apex:PageblockTable> 
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 Any help/suggestions would be greatly appreciated.

Thanks for your time and support