I have a list that contains a collection of wrapper class instances called tacList. The wrapper class effectively contains a checkbox which relates to a case field and a string. The string is not related to a case field but instead is intended to hold a comment for updating the case field which will later be posted to chatter. For some reason, the string value is not coming back into the apex class when I debug the response.
The wrapper fields: fieldPath, fieldLabel, fieldValue and field value all return the expected values. TaskComment is either null or blank.
Can anyone help? ...Thanks
public with sharing class GDPR_Dynamic_Extension {
public Case thisCase {get; set;}
public List <TaskAndComment> tacList {get; set;}
public List <Integer> indexList = new List<Integer>();
//Get the fields from FieldSet
Schema.SObjectType SObjectTypeObj = Schema.getGlobalDescribe().get('Case');
transient Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
transient Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get('GDPR_Task_Fields');
public Integer fieldSetSize = fieldSetObj.getFields().size();
public List<Integer> getIntegers() {
indexList = createIndex(fieldSetSize);
return indexList;
}
public GDPR_Dynamic_Extension(ApexPages.StandardController controller) {
controller.addFields(new String[]{
'GDPR_IS_Apps__c',
'GDPR_TON_Head__c'
});
thisCase = (Case)controller.getRecord();
tacList = new List<taskAndComment>();
}
public List<taskAndComment> getTheList() {
if (tacList.isEmpty()) {
for (Schema.FieldSetMember eachFieldSetMember : fieldSetObj.getFields()) {
String path = eachFieldSetMember.getFieldPath();
String label = eachFieldSetMember.getLabel();
Boolean value = (Boolean)thisCase.get(eachFieldSetMember.getFieldPath());
taskAndComment t = new taskAndComment(path, label, value);
tacList.add(t);
}
return tacList;
} else return tacList;
}
public PageReference processSelected() {
for (Integer i = 0; i < tacList.size() ; i++) {
thisCase.put(tacList[i].fieldPath, tacList[i].fieldValue);
System.debug(tacList[i].taskComment);
}
update thisCase;
return null;
}
public class TaskAndComment{
public String fieldPath {get; set;}
public String fieldLabel {get; set;}
public Boolean fieldValue {get; set;}
public String taskComment {get; set;}
public TaskAndComment(String theFieldPath, String theFieldLabel, Boolean theFieldValue){
System.debug('5');
fieldPath = theFieldPath;
fieldLabel = theFieldLabel;
fieldValue = theFieldValue;
taskComment = '';
}
}
public static List<Integer> createIndex(Integer count){
List<Integer> indexList = new List<Integer>();
for (Integer i = 0; i < count; i++) {
indexList.add(i);
}
return indexList;
}
public void postToChatter(Id c, String message){
ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), c, ConnectApi.FeedElementType.FeedItem, message);
}
}
..VF page:
<apex:page id="GDPR_Dynamic" StandardController="Case" extensions="GDPR_Dynamic_Extension">
<apex:form>
<apex:pageBlock>
<apex:pageBlockButtons >
<apex:commandButton value="Update Selected" action="{!processSelected}" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Incomplete Tasks" columns="3">
<apex:pageBlockTable value="{!Integers}" var="i" id="theRepeat">
<apex:column>
<apex:facet name="header">Name</apex:facet>
<apex:facet name="footer"></apex:facet>
<apex:outputText value="{!TheList[i].fieldLabel}" rendered="{!IF(!TheList[i].fieldValue=true,true,false)}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Task</apex:facet>
<apex:facet name="footer"></apex:facet>
<apex:inputCheckbox value="{!TheList[i].fieldValue}" rendered="{!IF(!TheList[i].fieldValue=true,true,false)}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Comment</apex:facet>
<apex:facet name="footer"></apex:facet>
<apex:inputText value="{!TheList[i].taskComment}" rendered="{!IF(!TheList[i].fieldValue=true,true,false)}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Complete Tasks" columns="3">
<apex:pageBlockTable value="{!Integers}" var="i" id="theRepeat">
<apex:column>
<apex:facet name="header">Name</apex:facet>
<apex:facet name="footer"></apex:facet>
<apex:outputText value="{!TheList[i].fieldLabel}" rendered="{!IF(!TheList[i].fieldValue=false,true,false)}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Task</apex:facet>
<apex:facet name="footer"></apex:facet>
<apex:inputCheckbox value="{!TheList[i].fieldValue}" disabled="true" rendered="{!IF(!TheList[i].fieldValue=false,true,false)}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Comment</apex:facet>
<apex:facet name="footer"></apex:facet>
<apex:inputText value="{!TheList[i].taskComment}" disabled="true" rendered="{!IF(!TheList[i].fieldValue=false,true,false)}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>