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
EMHDevEMHDev 

actionSupport with selectOptions - event not firing?

I'm trying to enhance a VF page so that when when an opportunity is selected from a picklist, the contact list on the page is filtered to only show the contacts related via OpportunityContactRole, and vice versa.  I've used actionSupport for this, but the event is not firing. I've put a debug statement into the controller to tell me whether the action method is called, but it is not being called.

 

I can't see that I've done anything different to the examples I've seen, or the actionSupport with the inputField in my code, which is working.  Are there restrictions with being able to use actionSupport from within an action region that is rerendered from another part of the page?

 

Here is the code:

 

<apex:pageBlock title="Call/Meeting Report" mode="edit" id="thePageBlock"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:inputField value="{!Call_Meeting_Report__c.Account__c}" required="true"> <apex:actionSupport event="onclick" action="{!getDetails}" rerender="opps, conts"/> </apex:inputField> <apex:pageBlockSectionItem > <apex:outputLabel value="Opportunity "/> <apex:selectList value="{!Call_Meeting_Report__c.Opportunity__c}" id="opps" size="1"> <!-- here is one of the actionSupports that is not firing --> <apex:selectOptions value="{!Opps}"/> <apex:actionSupport event="onchange" action="{!refreshContacts}" rerender="conts"/> </apex:selectList> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Contact "/> <apex:selectList value="{!Call_Meeting_Report__c.Primary_Contact__c}" id="conts" size="1"> <apex:selectOptions value="{!Conts}"/> <!-- here is the other one of the actionSupports that is not firing --> <apex:actionSupport event="onChange" action="{!refreshOpps}" rerender="opps"/> </apex:selectList> </apex:pageBlockSectionItem> <apex:inputField required="true" value="{!Call_Meeting_Report__c.Date__c}" /> <apex:inputField value="{!Call_Meeting_Report__c.Type__c}" required="true"/> <apex:inputField value="{!Call_Meeting_Report__c.Purpose__c}" required="true"/> <apex:inputField value="{!Call_Meeting_Report__c.Other_people_present__c}" style="width: 100%;" required="true"/> <apex:inputField value="{!Call_Meeting_Report__c.Call_Meeting_Objectives__c}" style="width: 100%;" required="true"/> <apex:inputField value="{!Call_Meeting_Report__c.Discussion__c}" style="width: 100%;" required="true"/> <apex:inputField value="{!Call_Meeting_Report__c.Next_actions__c}" style="width: 100%;" required="true"/> <apex:pageBlockSectionItem /> </apex:pageBlockSection> </apex:pageBlock>

 The relevant code in the controller (don't want the post the whole controller, it is quite long):

 

private Id a, newa, OppThere, ContThere; // Initialise the controller public ReportSearchController(ApexPages.StandardController controller) { //initialise the standard controller this.controller = controller; cmr = (Call_Meeting_Report__c)controller.getRecord(); } public void refreshContacts(){ system.debug('### in refreshcontacts'); OppThere = cmr.Opportunity__c; popContlist(OppThere); } public void refreshOpps(){ system.debug('### in refreshopps'); ContThere = cmr.Primary_Contact__c; popOpplist(ContThere); }

 The debug statements never appear in the system log.

 

Can anyone see what I'm doing wrong?

 

Thanks

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
EMHDevEMHDev

From looking at other actionSupport postings on the board, I realised that it may be because all of the fields are required, so I wrapped the actionSupport calls in actionRegions and it now works.

All Answers

uptime_andrewuptime_andrew

How about using a PageReference for your "action" call, something along the lines of:

 

 

public PageReference refreshOpps() { system.debug('### in refreshopps'); ContThere = cmr.Primary_Contact__c; popOpplist(ContThere); return null; }

 

 

 

EMHDevEMHDev
No, this makes no difference at all.  The problem is that it isn't calling the method at all.  I don't think there is a problem with the method itself (although I am open to correction!) - I think it is something to do with my VF code structures.  But I can't for the life of me see what is wrong with it.
yvk431yvk431

Hi there ,

 

I didnt tested your code , just from my past experience  why dont you try using a select list inside an output panel and rerender the output panel from the action support.I think your code is getting executed but the changes are not rendering properly.Let me know if this is not the case .

EMHDevEMHDev
It is not the case - the debug statement in the code never gets executed.  You don't need an outputPanel unless you need to wrap it, which I don't.
EMHDevEMHDev

From looking at other actionSupport postings on the board, I realised that it may be because all of the fields are required, so I wrapped the actionSupport calls in actionRegions and it now works.

This was selected as the best answer