I’m trying to get an inputField that is an account lookup to fire on the change event using actionSupport
<actionRegion> <apex:inputField id="accountId" value="{!tempAsset.AccountId}" rendered="{! !invalidProfile}" required="true"> <apex:actionSupport event="onblur" action="{!ChangeAccount}" rerender="RERENDERS" /> </apex:inputField> </actionRegion>
I’ve read that this is a known issue here:
https://success.salesforce.com/ideaView?id=08730000000HD0MAAW
Is there a workaround? I read that wrapping an actionRegion would resolve this, but it still does not fire.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
This is tested code of passing value to Controller with actionSupport
and without using actionRegion
.
Rather than onblur
event, you can use onchange
.
Visualforce
<apex:page name="actionSupportPage" StandardController="Opportunity" extensions="ActionSupportController"> <apex:form > <apex:outputLabel > AccountId: </apex:outputLabel> <apex:inputField id="OpportunityId" value="{!opptyObj.AccountId}" required="true"> <apex:actionSupport event="onchange" reRender="values" action="{!passValueToController}" > </apex:actionSupport> </apex:inputField> <apex:outputText value="{!fieldValue}" label="You have selected:" id="values" /> </apex:form > </apex:page>
Controller
public class ActionSupportController { public Opportunity opptyObj{get;set;} public String fieldValue {get; set;} ApexPages.standardController stdController = null; public ActionSupportController(ApexPages.StandardController controller) { this.stdController = controller; opptyObj = new Opportunity(); } public void passValueToController() { fieldValue = opptyObj.AccountId; } }
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0