You need to sign in to do that
Don't have an account?
muriel
Wrapper CLass not returning value
HI,
I am using a wrapper class to display a list of cases with checkbox. only the selected cases should be processed
public class ParentCasestest {
public List<cCase> related {get; set;}
public String mysearchtext {get; set;}
public boolean selected {get; set;}
public Case setCtrl{get; set;}
//initialize controller
public ParentCasestest(ApexPages.StandardController stdController) {
this.setCtrl = (Case)stdController.getRecord();
}
public List <cCase> GetChildCases() {
if (related==null)
{
related = new list <cCase>();
System.debug('the value is: '+ setCtrl.id);
for(Case c : [select id, CaseNumber, Subject, description, Status,UpdateChildcases__c , child_update__c, account.name from Case where parentId=:setCtrl.id])
{
related.add(new cCase(c));
}
}
return related;
}
public PageReference processSelected() {
//We create a new list of Contacts that we be populated only with Contacts if they are selected
List<Case> selectedChild = new List<Case>();
System.debug('the value is: ');
//We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
for(cCase cCon: GetChildCases()) {
if(cCon.selected == true) {
selectedChild.add(cCon.con);
}
}
// Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
System.debug('These are the selected Contacts...');
for(Case con: selectedChild) {
List<CaseComment> childCom = new List<CaseComment>();
for(integer i=0;i<selectedChild.size();i++){
CaseComment newCom = new CaseComment();
newCom.CommentBody = mysearchtext;
newCom.IsPublished = TRUE;
newCom.ParentId = con.id;
childCom.add(newcom);
}
if(!childCom.isEmpty()){
insert childCom;
}
}
related=null; // we need this line if we performed a write operation because getContacts gets a fresh list now
return null;
}
public class cCase {
public Case con {get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new
// object we pass a Contact that is set to the con property. We also set the selected value to false
public cCase(Case c) {
con = c;
selected = false;
}
}
}
visual page
<apex:page standardController="Case" extensions="ParentCasestest">
<apex:pageBlock title="Child Cases" />
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>
<apex:outputLabel value="Comment" for="comment" style="font-weight:600"/><p/>
<apex:inputTextarea id="newDesc" value="{!mysearchtext}" rows="10" cols="150" /><p/>
</apex:pageBlock>
<apex:outputText value="this is a test" rendered="false" />
<apex:datatable value="{!related}" var="c" width="80%">
<apex:column headervalue="Select" width="10%">
<apex:inputCheckbox value="{!c.selected}"/><p/>
</apex:column>
<apex:column headervalue="Case Number" width="30%">
<apex:outputLink value="/{!c.con.casenumber}" target="_blank">{!c.con.casenumber}</apex:outputLink><p/>
</apex:column>
<apex:column headervalue="Account Name" width="30%">
<apex:outputLink value="/{!c.con.account.name}" target="_blank">{!c.con.account.name}</apex:outputLink><p/>
</apex:column>
<apex:column headervalue="Subject" width="30%">
<apex:outputLink value="/{!c.con.subject}" target="_blank">{!c.con.subject}</apex:outputLink><p/>
</apex:column>
</apex:datatable>
</apex:form>
</apex:page>
The page doesn't display anything at all.
i must be missing something....
I am using a wrapper class to display a list of cases with checkbox. only the selected cases should be processed
public class ParentCasestest {
public List<cCase> related {get; set;}
public String mysearchtext {get; set;}
public boolean selected {get; set;}
public Case setCtrl{get; set;}
//initialize controller
public ParentCasestest(ApexPages.StandardController stdController) {
this.setCtrl = (Case)stdController.getRecord();
}
public List <cCase> GetChildCases() {
if (related==null)
{
related = new list <cCase>();
System.debug('the value is: '+ setCtrl.id);
for(Case c : [select id, CaseNumber, Subject, description, Status,UpdateChildcases__c , child_update__c, account.name from Case where parentId=:setCtrl.id])
{
related.add(new cCase(c));
}
}
return related;
}
public PageReference processSelected() {
//We create a new list of Contacts that we be populated only with Contacts if they are selected
List<Case> selectedChild = new List<Case>();
System.debug('the value is: ');
//We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
for(cCase cCon: GetChildCases()) {
if(cCon.selected == true) {
selectedChild.add(cCon.con);
}
}
// Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
System.debug('These are the selected Contacts...');
for(Case con: selectedChild) {
List<CaseComment> childCom = new List<CaseComment>();
for(integer i=0;i<selectedChild.size();i++){
CaseComment newCom = new CaseComment();
newCom.CommentBody = mysearchtext;
newCom.IsPublished = TRUE;
newCom.ParentId = con.id;
childCom.add(newcom);
}
if(!childCom.isEmpty()){
insert childCom;
}
}
related=null; // we need this line if we performed a write operation because getContacts gets a fresh list now
return null;
}
public class cCase {
public Case con {get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new
// object we pass a Contact that is set to the con property. We also set the selected value to false
public cCase(Case c) {
con = c;
selected = false;
}
}
}
visual page
<apex:page standardController="Case" extensions="ParentCasestest">
<apex:pageBlock title="Child Cases" />
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>
<apex:outputLabel value="Comment" for="comment" style="font-weight:600"/><p/>
<apex:inputTextarea id="newDesc" value="{!mysearchtext}" rows="10" cols="150" /><p/>
</apex:pageBlock>
<apex:outputText value="this is a test" rendered="false" />
<apex:datatable value="{!related}" var="c" width="80%">
<apex:column headervalue="Select" width="10%">
<apex:inputCheckbox value="{!c.selected}"/><p/>
</apex:column>
<apex:column headervalue="Case Number" width="30%">
<apex:outputLink value="/{!c.con.casenumber}" target="_blank">{!c.con.casenumber}</apex:outputLink><p/>
</apex:column>
<apex:column headervalue="Account Name" width="30%">
<apex:outputLink value="/{!c.con.account.name}" target="_blank">{!c.con.account.name}</apex:outputLink><p/>
</apex:column>
<apex:column headervalue="Subject" width="30%">
<apex:outputLink value="/{!c.con.subject}" target="_blank">{!c.con.subject}</apex:outputLink><p/>
</apex:column>
</apex:datatable>
</apex:form>
</apex:page>
The page doesn't display anything at all.
i must be missing something....
<apex:datatable value="{!related}" var="c" width="80%">