Last active
April 21, 2017 06:28
-
-
Save ueki-kazuki/84c7ea6792a706eaf88f44b6a2150ed4 to your computer and use it in GitHub Desktop.
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="DynamicActionController"> | |
<apex:form > | |
<apex:actionFunction name="refreshResults" reRender="searchResults" status="searchStatus"/> | |
<apex:dataTable value="{!records}" var="rec" > | |
<apex:column > | |
<apex:inputCheckbox value="{!rec.checked}" onchange="return refreshResults()"/> | |
</apex:column> | |
<apex:column style="text-align:right;"> | |
<apex:inputText value="{!rec.value}" onchange="return refreshResults()"/> | |
</apex:column> | |
</apex:dataTable> | |
<apex:outputPanel id="searchResults"> | |
<apex:actionStatus id="searchStatus" startText="合計値を再計算しています..."/> | |
<apex:outputText value="{0, number, ###,###}"> | |
<apex:param value="{!total}"/> | |
</apex:outputText> 円 | |
</apex:outputPanel> | |
</apex:form> | |
</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 with sharing class DynamicActionController { | |
public class MyClass { | |
public Decimal value {get; set;} | |
public Boolean checked {get;set;} | |
public MyClass(Decimal value) { | |
this.checked = false; | |
this.value = value; | |
} | |
} | |
public List<MyClass> records {get;set;} | |
public DynamicActionController() { | |
this.records = new List<MyClass>(); | |
this.records.add(new MyClass(10000)); | |
this.records.add(new MyClass(2345)); | |
} | |
public Decimal getTotal() { | |
Decimal total = 0; | |
for(MyClass o : this.records) { | |
if (o.checked) { total += o.value; } | |
} | |
return total; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment