function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hemant Ghaturkar 8hemant Ghaturkar 8 

can we display data while selected record select from one page to other page by using wrapper class

can we display data while selected record select from one page to other page by using wrapper class
abhishek singh 497abhishek singh 497
Hello Hemant,

please go through the below link:-

http://forceforte.com/display-selected-records-of-one-visualforce-page-on-another-visualforce-page/

I hope the above link will help you. If you find it good enough please mark it has the best one.

Thanks & Regards,
Abhishek Singh.
abhishek singh 497abhishek singh 497
Hello Hemant,

another link you can find helpful.

http://whatasalesforce.blogspot.com/2016/12/wrapper-class-for-displaying-selected.html
Saravanan RajarajanSaravanan Rajarajan
Hi Hemant,

Wrapper class for displaying the selected records in Next page

Example Code:

Page 1: (t12)

 
<apex:page sidebar="false" controller="WrapTestClass">
<apex:form >
<apex:pageblock >
<apex:pageblocksection >
<apex:pageblocktable value="{!testingrecords}" var="tr">
<apex:column headervalue="Action">
<apex:inputcheckbox value="{!tr.ischecked}"/>
</apex:column>
<apex:column headerValue="Name">
{!tr.TName}
</apex:column>
<apex:column headerValue="City">
{!tr.TCity}
</apex:column>
</apex:pageblocktable>
</apex:pageblocksection>
</apex:pageblock>
<apex:commandButton value="SELECT" action="{!selRecDisplay}"/>
</apex:form>
</apex:page>

Class 1: (WrapTestClass)
 
public with sharing class WrapTestClass {
	List<string> lstselectedNames = new List<string>();
	public PageReference selRecDisplay() {
		for(wrapper w: lstwrap){
			if(w.ischecked==true){
				lstselectedNames.add(w.Tname);
			}
		}
		List<Testing__c> lstselectedrecords = [select Id,name,city__c from Testing__c where name in : lstselectedNames];
		List<String> lstselectedRecordIds = new List<String>();
		for(Integer i=0;i<lstselectedrecords.size();i++){
			lstselectedRecordIds.add(lstselectedrecords[i].Id);
		}
		string s='';
		for(Integer i=0;i<lstselectedRecordIds.size();i++) {
			if(i<lstselectedRecordIds.size()-1)
			s=s+lstselectedRecordIds[i]+':';
			else
			s=s+lstselectedRecordIds[i];
		}
		pagereference ref = new pagereference('/apex/t123?value='+s);
		ref.setredirect(true);
		return ref;
	}
 
	List<wrapper> lstwrap = new List<wrapper>();
	List<Testing__c> lsttest = new List<Testing__c>();
	public List<wrapper> getTestingrecords() {
		lsttest = [select Id,name,city__c from Testing__c];
		for(Integer i=0;i<lsttest.size();i++) {
			lstwrap.add(new wrapper(lsttest[i].name,lsttest[i].city__c));
		}
		return lstwrap;
	}
	public class wrapper{
		public String Tname{get;set;}
		public String Tcity{get;set;}
		public boolean ischecked{get;set;}
		public wrapper(String Tname,String Tcity) {
			this.Tname=Tname;
			this.Tcity=Tcity;
			this.ischecked=false;
		}
	}
}

Page 2: (t123)
 
<apex:page controller="DClass">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!records}" var="r">
<apex:column headerValue="Name">
{!r.Name}
</apex:column>
<apex:column headerValue="City">
{!r.City__c}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Class 2: (DClass)
 
public with sharing class DClass {
	List<Testing__c> lsttest = new List<Testing__c>();
	public List<Testing__c> getRecords() {
		List<String> ids = url.split(':');
		lsttest = [select Id,name,city__c from Testing__c where id in : ids];
		return lsttest;
	}
	String url = apexpages.currentpage().getparameters().get('value');
}

​​​​​​​Please mark it best answer if it helps you.