You need to sign in to do that
Don't have an account?
Rohan Suresh
actionSupport not not triggering Controller action
Hello,
I have this strange issue where the actionSupport is failing to execute Controller action. It works properly for couple of clicks/selections but after that it doesnt do anything.
Below is the code snippet:
Vikesh Gajula
I have this strange issue where the actionSupport is failing to execute Controller action. It works properly for couple of clicks/selections but after that it doesnt do anything.
Below is the code snippet:
!-- Visualforce page code --! <apex:page controller="sampleCon"> <apex:form > <apex:selectList id="ddlVCs" label="Vertical Unit / Accounts" value="{!SelectedVCs}" > <apex:selectOptions value="{!ValueCorridors}"></apex:selectOptions> <apex:actionSupport event="ondblclick" action="{!FetchAccountsForVC}" rerender="out1" status="myStatus1" /> <apex:actionStatus id="myStatus1" startText="Please Wait..." /> </apex:selectList> <apex:outputPanel id="out1" > <apex:selectList id="ddlAccounts" label="Accounts" value="{!SelectedAccounts}"> <apex:selectOptions value="{!AccountsList}"></apex:selectOptions> </apex:selectList> </apex:outputPanel> </apex:page> !-- Controller Class Code --! public class sampleCon { String selVCs; String[] selectedAccounts = new String[]{}; List<SelectOption> lstAccountsForVC = new List<SelectOption>(); String TempVar; public PageReference test() { return null; } public List<SelectOption> GetValueCorridors() { List<Account> lstVC = [SELECT Value_Corridor__c FROM Account where Business_Unit__c = 'Business Unit UK (BU-UK)']; List<SelectOption> options = new List<SelectOption>(); If(lstVC.size() > 0) { for(Account Acc : lstVC) { options.add(new SelectOption(Acc.Value_Corridor__c, Acc.Value_Corridor__c)); } } return options; } public String getSelectedVCs() { return selVCs; } public void setSelectedVCs(String SelectedVCs) { this.selVCs = SelectedVCs; } public PageReference FetchAccountsForVC() { TempVar = selVCs; List<Account> lstAccounts = [SELECT Id, Name FROM Account where Value_Corridor__c = :selVCs]; List<SelectOption> options = new List<SelectOption>(); If(lstAccounts.size() > 0) { for(Account Acc : lstAccounts) { options.add(new SelectOption(Acc.Id, Acc.Name)); } } lstAccountsForVC = options; return null; } public List<SelectOption> getAccountsList() { return lstAccountsForVC; } public String[] getSelectedAccounts() { return selectedAccounts; } public void setSelectedAccounts(String[] SelectedAccounts) { this.selectedAccounts = SelectedAccounts; } }Thanks,
Vikesh Gajula
Please Use Onchange instead of using ondblclick for SelectList.
<apex:actionSupport event="onChange" action="{!FetchAccountsForVC}" rerender="out1" status="myStatus1" />
Thanks for your response.. I have also tried onChange, onClick events but it works the same.
If you see the code, I have used a variable 'tempVar' which is set inside the action but when i check the viewstate the value remains the same irrespective of item selected in the list. Which means the controller action is not getting called after initial call.