Forked from martyychang/ActionSupportParamDemo.page
Created
December 20, 2015 23:09
-
-
Save reuf/256c097301e92fe39cf5 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 hidden or 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 hidden or 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