+ Start a Discussion
AshesAshes 

How to parse object of wrapper class

Hello,

We have a wrapper class in our logic which we are using to display list of checkboxes and records on visualforce page.
public class wrapper
      {
         public Subscription_Fees__c fee {get;set;}
         public boolean bSelected {get;set;}
         
         public Wrapper(Subscription_Fees__c f, boolean selected){
             fee=f;
             bSelected=selected;
         }
      }

whenever we select record, it will pass value to controller through Param tag.  

<apex:actionFunction action="{!togglecheckBox}" name="passparam" reRender="payterms, showselected">
        <apex:param name="myParam1" value="" />
 </apex:actionFunction>

<apex:pageBlockTable value="{!wrapper}" var="f" align="center" rules="none" width="80%" id="FeeList"> <apex:column headerValue="Select" > <apex:inputCheckbox value="{!f.bSelected}" onclick="passparam('{!f}');" /> </apex:column> <apex:column headerValue="Product Name" ><apex:outputField value="{!f.fee.product__r.name}" /> </apex:column> <apex:column headerValue="Invoice_Product_Description__c" ><apex:outputField value="{!f.fee.Invoice_Product_Description__c}" /> </apex:column> </apex:pageBlockTable>

if I am passing instance of object (onclick="passparam('{!f}'))..., it is passing the object but I am not able to parse it in controller.

Is there any way that I can do that?

Thanks,

Ashes
 

AshesAshes
It is giving me value like this in controller:
Wrapper:[bSelected=true, fee=Subscription_Fees__c:{Subscription__c=aCj630000000001CAA, Id=aCg630000008OM4CAM, Product__c=01t32000004TXA8AAO, Invoice_Product_Description__c=HR Only Employees, RecordTypeId=01232000000M3JaAAK, CurrencyIsoCode=USD}]

And I dont know how to parse it.
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help you
1) https://developer.salesforce.com/page/Wrapper_Class
2) https://www.minddigital.com/what-is-wrapper-class-and-how-to-use-it-in-salesforce/

Please check 1 post for parsing logic "processSelected"
public PageReference processSelected() 
	{
		List<Subscription_Fees__c > selectedSub = new List<Subscription_Fees__c >();

		for( Wrapper wapp: listwrapper ) 
		{
			if(wapp.bSelected  == true) 
			{
				selectedSub.add(wapp.fee );
			}
		}

		for(Subscription_Fees__c sub : selectedSub) 
		{
			System.debug(con);
		}
		return null;
	}
	
	public class wrapper
    {
        public Subscription_Fees__c fee {get;set;}
        public boolean bSelected {get;set;}
         
        public Wrapper(Subscription_Fees__c f, boolean selected)
		{
            fee=f;
            bSelected=selected;
        }
    }
Please let us know if this will help you