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
Mitesh SuraMitesh Sura 

apex:actionSupport does not work with immediate=true

 

 

Here is the thing, I have few required fields and country and state picklist. I would like country and state to function irrepctecive of values in required fields.

 

I see some posts which says to remove requires=true for the fields and move the validation in the controller. I really do not want to do that. Below is the snippet, what esle can be done?

 

 

<apex:selectList value="{!country}" size="1"> 
  <apex:selectOptions value="{!Countries}" /> 
  <apex:actionSupport event="onchange" rerender="states" immediate="true" /> 
</apex:selectList> 

<apex:outputPanel id="states" > 
  <apex:selectList value="{!state}" size="1"> 
    <apex:selectOptions value="{!States}" /> 
  </apex:selectList> 
</apex:outputPanel> 

 Above code will work if have required=false and all required fields have a value.

 

Thank you for your time.

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
AshlekhAshlekh

Hi ,

If you put immediate= true than you will never get any value in controller. Means When ever we use immediate =true than setter method of property and validation are not fired so our data(which are in form and form which is submited) will not post at server.
So we can use apex:actionregion for that section which should be submit and no other data will execute their validaion.

Thanks
Ashlekh

If this post help you than please mark it as a solution and give me kudo's

All Answers

AshlekhAshlekh

Hi ,

If you put immediate= true than you will never get any value in controller. Means When ever we use immediate =true than setter method of property and validation are not fired so our data(which are in form and form which is submited) will not post at server.
So we can use apex:actionregion for that section which should be submit and no other data will execute their validaion.

Thanks
Ashlekh

If this post help you than please mark it as a solution and give me kudo's

This was selected as the best answer
Avidev9Avidev9

Well the solution should be easy!

Use a actionregion along with action support, this will avoid submitting the full page and hence you will not get any error from rest part of the page

 

 

<apex:actionRegion>
<apex:selectList value="{!country}" size="1"> 
  <apex:selectOptions value="{!Countries}" /> 
  <apex:actionSupport event="onchange" rerender="states" /> 
</apex:selectList> 
</apex:actionRegion>

 

Mitesh SuraMitesh Sura
Thanks Asklekh and Avi. For now we are using jQuery, but I looked in the documentation actionRegion would have worked just fine too.
Akshay DeshmukhAkshay Deshmukh
you can check my post at following link for action:region tag
http://dattarajsfdc.wordpress.com/