+ Start a Discussion
dmchengdmcheng 

actionSupport not working?

Hello.  I have a VF page showing a list of records in a pageblocktable.  I have an inputText field on the page where the user can enter a value to filter the list.  When the user enters the value, I'll re-query the data and rerender the pageblocktable.

I'm trying to use actionRegion and actionSupport for this, but it's not working.  The filterByName method never gets called.

Can anyone tell me what I'm doing wrong?  Does it have to do with onChange, or with the form submission process?  There are no other input fields on the page.

Here's a snippet of the VF page:
<apex:form >
	<div class="ccx-list-header">
		<div class="ccx-advocate-buttons" id="bulkListActions">
			<apex:actionRegion immediate="true">
				<apex:inputText value="{!searchName}" html-placeholder="Search for advocate">
					<apex:actionSupport action="{!searchAdvocate}" reRender="advocateListTable" event="onchange" />
				</apex:inputText>
			</apex:actionRegion>
		</div>
	</div>
</apex:form>

Here's a snippet from the controller:
public class MyController {
        public String currentDeskId;
	public String searchName { get; set; }
        public List<CCx_AdvocateServices.onboardingAdvocateDecorator> advocates { get; set; }

	public void filterByName() {
		system.debug('*** searchName: ' + searchName);
		if (string.isBlank(searchName)) return;
		advocates = CCx_AdvocateSelector.selectAdvocateDecoratorForDeskAndName(currentDeskId, searchName);
		system.debug('*** advocates: ' + advocates);
		searchName = null;
	}
	
	// Constructor
	// etc
}


Sonam_SFDCSonam_SFDC
You are rerendering "advocateListTable" but I don't see any of the component section with id: advocateListTable 

The Id of the section you are rerendering should be the one which contains the values returned to the page after the filter is applied.
dmchengdmcheng
The original post had the wrong version of code snippets, here's the correct version:

<apex:form >
	<div class="ccx-list-header">
		<div class="ccx-advocate-buttons" id="bulkListActions">
			<apex:actionRegion immediate="true">
				<apex:inputText value="{!searchName}" html-placeholder="Search for advocate">
					<apex:actionSupport action="{!filterByName}" event="onchange" />
				</apex:inputText>
			</apex:actionRegion>
		</div>
	</div>
</apex:form>

public class MyController {
	public String currentDeskId;
	public String searchName { get; set; }
	public List<CCx_AdvocateServices.onboardingAdvocateDecorator> advocates { get; set; }

	public void filterByName() {
		system.debug('*** searchName: ' + searchName);
		if (string.isBlank(searchName)) return;
		advocates = CCx_AdvocateSelector.selectAdvocateDecoratorForDeskAndName(currentDeskId, searchName);
		system.debug('*** advocates: ' + advocates);
		searchName = null;
	}
	
	// Constructor
	// etc
}