Created
December 12, 2014 15:44
-
-
Save martyychang/a3e6cefa272e3dd716a1 to your computer and use it in GitHub Desktop.
Demonstration of how apex:actionSupport and apex:param are supposed to work together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="ActionSupportParamDemoController"> | |
<apex:form> | |
<apex:repeat value="{!accounts}" var="account"> | |
<apex:inputCheckbox value="{!account.IsActive__c}"> | |
<apex:actionSupport event="onchange" | |
action="{!handleAccountCheckboxChange}"> | |
<apex:param id="account" name="accountId" value="{!account.Id}" | |
assignTo="{!targetAccountId}"/> | |
</apex:actionSupport> | |
</apex:inputCheckbox> | |
{!account.Name} | |
</apex:repeat> | |
</apex:form> | |
Selected: {!selectedAccountId} | |
</apex:page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ActionSupportParamDemoController { | |
private Id targetAccountId; | |
public Id selectedAccountId { get; set; } | |
public List<Account> getAccounts() { | |
return [ | |
SELECT Id, Name, Website, IsActive__c | |
FROM Account | |
]; | |
} | |
public Id getTargetAccountId() { | |
return targetAccountId; | |
} | |
public PageReference handleAccountCheckboxChange() { | |
System.debug('targetAccountId: ' + targetAccountId); | |
selectedAccountId = targetAccountId; | |
return null; | |
} | |
public void setTargetAccountId(Id value) { | |
targetAccountId = value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am getting null as AccountId... Can you please verify