[SalesForce] How to use ActionSupport, ActionREgion, ActionFunction all together

I have a requirement, where I have a dropdown fiter. On change of dropdown value, Pageblocktable will be updated.

Dropdown field has no Button to excute the event, so it has to be ActionFunction.

But when I am changing the Dropdown value, it is throwing error that

I must have enter some required field value.

I know I must use ActionRegion and ActionSupport. To avoid sending entire page to the server.

Page :

 <apex:form >
      <apex:actionFunction action="{!OnChangeType}" status="working" rerender="pgBlockTable"/>
      <script>
          function categoryTypeChangeNow(type) {
              categoryTypeChangeNow();
          }

      </script>

    <apex:pageBlockSection collapsible="false" columns="1">
         <apex:pageBlockSectionItem >
         <apex:outputLabel value="Filter"/>
         <apex:actionRegion >
               <apex:selectList id="Type" value="{!selectedVal}" size="1" multiselect="false" onchange="categoryTypeChangeNow(this)">
                    <apex:selectOptions value="{!customList}"/>
                </apex:selectList>
               <apex:actionSupport event="onchange" reRender="ajaxrequest" />
        </apex:actionRegion>

         </apex:pageBlockSectionItem>                                

Best Answer

You can try to use your action method and reRender parameter directly from the actionSupport. And wrap your list with an actionRegion. You then don't need an extra javascript function and actionFunction. Something like this:

<apex:actionRegion>
<apex:selectList id="Type" value="{!selectedVal}" size="1" multiselect="false">
    <apex:selectOptions value="{!customList}"/>
    <apex:actionSupport event="onchange" reRender="ajaxrequest" action="{!OnChangeType}"
                        status="working"/>
</apex:selectList>
</apex:actionRegion>