You need to sign in to do that
Don't have an account?
Wrapper Class Issue in Sites
Hi EveryOne ,
I am facing an Issue in Wrapper Class in Sites . When I pass my wrapper class instance in the Login method then it is returning null.I have used my wrapper donationList list in many methods it is having value in those methods . I have also used getParameters and putParameters of ApexPages but it will only show me the 1st row record in my wrapper List.I want to insert many records based on my wrapper class values when the User is directed to the Customer Portal after logging in.Please help me with this Problem , I need to get my whole Wrapper List values in Login method. In short I want to pass the List<Donation> value from one method to another when View state is null .
public with sharing class CustomUserSiteRegister
{
public PageReference goToSiteLoginPage()
{
PageReference pageRef = new PageReference('/apex/SiteLogin');
pageRef.setRedirect(false);
system.debug('this is DonationList111111111'+donationList);
pageRef.getParameters().put('totalAmount123',string.valueOf(totalAmount));
for(Donation donPassParam : donationList)
{
putAmountParam = string.valueOf(donPassParam.wFundAllocation.Amount__c);
putDonationTypeParam = donPassParam.wFundAllocation.Donation_Type__c;
putFundParam = donPassParam.wFundAllocation.Fund__c;
putProgrammeParam = donPassParam.wFundAllocation.Programme__c;
}
return pageRef;
}
public PageReference login()
{
PageReference pr= Site.login(username, password, '/apex/LoginPayment');
pr.setRedirect(false);
system.debug(‘this is donationList’+ donationList);
return pr;
}
List< Donation > donationList = new List< Donation >();
public class Donation
{
public Fund_Allocation__c wFundAllocation{get;set;}
public Boolean wIsSelected{get;set;}
public Donation( Fund_Allocation__c fundAllocation ,Boolean IsSelected)
{
wFundAllocation=fundAllocation;
wIsSelected = IsSelected;
}
}
}
Hi Avi,
FYI my code is below if you can tell me the Solution:
public with sharing class CustomUserSiteRegister
{
public string password {get; set;}
public String username {get; set;}
public String isSingleDonation {get{if(null ==isSingleDonation)
{
isSingleDonation = 'Single';
}
return isSingleDonation;
}
set;}
public List<selectOption> getSingleDonation()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Single',' singledon'));
options.add(new SelectOption('Multiple',multiple'));
return options;
}
public PageReference login()
{
PageReference pr= Site.login(username, password, '/apex/LoginPayment');
Opportunity opp = new Opportunity();
if(pr != null)
{
User usr = [Select id, Username , ContactId , LastName, FirstName from User where Username =:username ];
Id con = usr.ContactId ;
if(fund.Donation_Option__c.equals('Monthly Donation'))
{
RecordType rec1 = [select DeveloperName ,SobjectType from recordtype where SobjectType = 'Opportunity' and DeveloperName = 'Non_Recurring' and IsActive = true];
PortalAccount__c custSetting1 = PortalAccount__c.getInstance('Account Id');
id accId = custSetting1.Account_Number__c;
if(isSingleDonation.equals('Single'))
{
opp.Name = usr.FirstName + usr.LastName+ 'Single Donation';
}
else
{
if(isSingleDonation.equals('Multiple'))
{
opp.Name = usr.FirstName + usr.LastName+ 'Multiple Donation';
}
}
opp.RecordTypeId = rec1.Id;
opp.AccountId = accId;
opp.CloseDate = system.today();
opp.StageName = 'Prospecting';
opp.Donor_Contact__c = con;
insert opp;
fundWithRelatedDonation(donationList , opp);
}
else
{
if(fund.Donation_Option__c.equals('Single Donation'))
{
RecordType rec1 = [select DeveloperName ,SobjectType from recordtype where SobjectType = 'Opportunity' and DeveloperName = 'Non_Recurring' and IsActive = true];
PortalAccount__c custSetting1 = PortalAccount__c.getInstance('Account Id');
id accId = custSetting1.Account_Number__c;
if(isSingleDonation.equals('Single'))
{
opp.Name = usr.FirstName + usr.LastName+ 'Single Donation';
}else{
if(isSingleDonation.equals('Multiple'))
{
opp.Name = usr.FirstName + usr.LastName+ 'Multiple Donation';
}
}
opp.RecordTypeId = rec1.Id;
opp.AccountId = accId;
opp.CloseDate = system.today();
opp.StageName = 'Prospecting';
opp.Donor_Contact__c = con;
insert opp;
}
}
//Here the donationList is coming null
for(Donation don : donationList)
{
Fund_Allocation__c fundAllocate = new Fund_Allocation__c();
if(don.wFundAllocation.Amount__c != 0.00)
{
fundAllocate.Amount__c = don.wFundAllocation.Amount__c;
fundAllocate.Donation_Type__c = don.wFundAllocation.Donation_Type__c;
fundAllocate.Fund__c = don.wFundAllocation.Fund__c;
fundAllocate.Programme__c = don.wFundAllocation.Programme__c;
fundAllocate.Donation__c = opp.id;
insert fundAllocate;
}
}
}
return pr;
}
public class Donation
{
public Fund_Allocation__c wFundAllocation{get;set;}
public Boolean wIsSelected{get;set;}
public Donation( Fund_Allocation__c fundAllocation ,Boolean IsSelected)
{
wFundAllocation=fundAllocation;
wIsSelected = IsSelected;
}
}
}
public list<Donation> donationList {get{if(null==donationList)
{
donationList = new list<Donation>();
for(integer i=0;i<3;i++)
{
donationList.add(new Donation(new Fund_Allocation__c(Amount__c=0.00),false));
}
}
return donationList;
}
set;}
Initially I am showing three rows...
Lets make the code lil simple
Declare a class variable by doing something like
Populate the list from the constructor(the below code should go in the constructor)