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
sivapriyaa maniam sivakumarsivapriyaa maniam sivakumar 

How to pass a VisualForce Page1 to Another VisualForce Page2

Hi,
Can anyone please tell me the solution.

Scenario:
By passing Academic Year & Student Name from VisualForce Page1 to VisualForce Page2 (Single Student Records-Student Profile,Academics,Family and Counselling) have to display 
2 VFP and 1 Apex Controller.
Issue:
For VisualForce Page 2, Apex Controller [getStud() & getstudentrec() ] didn't enter these two methods ,But ID is passing to the second VisualForce Page , another methods(getFamily() & getstudentcounsel()) are displayed.

Note: Totally 4 methods has to pass on the VisualForce Page 2 , out of 2 [getFamily() & getstudentcounsel()] is display other 2 [getStud() & getstudentrec() ] is not display.
Apex code:
public with sharing class StudentProfileListViewTest {
    
    private String soql {get;set;}
     public string StudentName {get;set;}
     public string Year {get;set;}
    public string School {get;set;}
    public CSM_Student_Profile__c studentrec;
public Student_Counselling_Attributes__c studentcounsel;
    public Student_Academic_Class__c stud{get;set;}
  ID qstr = System.currentPagereference().getParameters().get('Id');
    public List<Student_Academic_Class__c> StudDetail{get;set;}
    
    public StudentProfileListViewTest() {
     soql='SELECT Year__c,name,Student_Name__r.Name,Student_Name__r.Student_First_Name__c,Student_Name__r.Student_Last_Name__c,Student_Name__r.Student_Caste__c,Student_Name__r.State__c,Student_Name__r.City__c,Student_Name__r.Address__c,School_Name__r.School_Name__c from Student_Academic_Class__c order by Year__c limit 200';  

        runquery();
    }
     public void search_method() {
         
    soql='SELECT Year__c,name,Student_Name__r.Name,Student_Name__r.Student_First_Name__c,Student_Name__r.Student_Last_Name__c,Student_Name__r.Student_Caste__c,Student_Name__r.State__c,Student_Name__r.City__c,Student_Name__r.Address__c,School_Name__r.School_Name__c from Student_Academic_Class__c where Year__c!=null';  
      system.debug('Full Query'+soql);
      if (!StudentName.equals(''))
      soql += ' and Student_Name__r.Student_First_Name__c LIKE \''+String.escapeSingleQuotes(StudentName)+'%\'';  
       if (!Year.equals('selectst'))
      soql += ' and Year__c  LIKE \''+String.escapeSingleQuotes(Year)+'%\''; 

              system.debug('year'+year);  
    // run the query again
  runQuery();
     }

 public void runQuery() 
{

    try {
system.debug('Query'+soql);
      StudDetail= Database.query(soql);
 
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'+e));
    }
 
   }
     public List<selectoption> getAcademicYear()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Student_Academic_Class__c.Year__c.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
        options.add(new SelectOption('selectst','-- Select Academic Year --')); 
    for (Schema.PicklistEntry a : values) 
    {     
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 
} 
    
    public List<SelectOption> getSchoolName() {

    List<SelectOption> options = new List<SelectOption>();

    options.add(new SelectOption('selectprd','-- Select SchoolName --'));

    for(Schools_Master__c c : [select ID, School_Name__c from Schools_Master__c]){

        options.add(new SelectOption(c.ID, c.School_Name__c));

    } 

    return options;

}
    public PageReference StudPage(){
        System.debug('111111111111111');
        string id1 = apexpages.currentpage().getparameters().get('StudId');
       
         //stud= [SELECT Name, Student_Name__r.Name, Pass_Fail__c,Medium_of_Instruction__c, Year__c, (select subject_name__c, first_exam_marks__c,second_exam_marks__c,final_exam_marks__c from Student_Scores__r), Total_Marks__C, Total_Percentage__c, Math_Marks__C, Science_Marks__c, Social_Science_Marks__C, First_Language_Marks__C, Second_Language_Marks__C,  English_Language_Marks__c,School_Name__r.School_Name__c, School_Name__r.State__c, School_Name__r.Village_Name__c FROM Student_Academic_Class__c WHERE year__c = : year and Student_Name__c = : id1  ORDER BY name];
      system.debug(id1);
         system.debug(year);
        PageReference ref = new PageReference('/apex/testltning?id='+id1);
  
       ref.setRedirect(true);
        return ref;
    }
   
     
    public CSM_Student_Profile__c getstudentrec(){ 
        system.debug('22222');
        studentrec= [SELECT Name,Student_First_Name__c,Student_Last_Name__c,Student_Caste__c,State__c,City__c,Address__c,External_Student_Id__c FROM CSM_Student_Profile__c WHERE Id = :qstr ORDER BY name];
        system.debug('ID'+qstr);
        return studentrec;

    }
    
   public Student_Academic_Class__c getStud(){   
       system.debug('3333');
      return [SELECT Name, Student_Name__r.Name, Pass_Fail__c,Medium_of_Instruction__c, Year__c, (select subject_name__c, first_exam_marks__c,second_exam_marks__c,final_exam_marks__c from Student_Scores__r), Total_Marks__C, Total_Percentage__c, Math_Marks__C, Science_Marks__c, Social_Science_Marks__C, First_Language_Marks__C, Second_Language_Marks__C,  English_Language_Marks__c,School_Name__r.School_Name__c, School_Name__r.State__c, School_Name__r.Village_Name__c FROM Student_Academic_Class__c WHERE year__c = : year  and Student_Name__c = : qstr  ORDER BY name];
     
        
    }
      
     public List<Student_Family_Education_Income__c> getFamily(){   
         system.debug('44444');
        return [SELECT Name,Education_Level__c,Relationship_with_Student__c,Occupation__c,Monthly_Income__c FROM Student_Family_Education_Income__c  WHERE Student_Name__c = :qstr ORDER BY name];
    }
      
    public Student_Counselling_Attributes__c getstudentcounsel(){  
        system.debug('5555');
        studentcounsel= [SELECT Name, Childs_Interest__c, Parents_Interest__c, Travel_For_Education__c, Extra_Curricular_Activities__c,Role_Model__c,Family_Funding_Education_Method__c,Family_Open_to_meeting_to_understand_Ed__c,Family_Understand_Cost_of_Hr_Ed__c,Family_Understand_Hr_Ed_Options__c,Highest_Ed_Level_in_Family__c,Holland_Code__c,Relatives_who_can_fund_education__c FROM Student_Counselling_Attributes__c WHERE Student_Name__c = :qstr ORDER BY name];
         return studentcounsel;
    }
  

}

VisualForce Page 1:
 
<apex:page controller="StudentProfileListViewTest" title="Students Record" sidebar="false" docType="html-5.0">
    
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" />
    <apex:includeScript value="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js" />
    <apex:stylesheet value="{!URLFOR($Resource.SLDS0120, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

    <apex:form >
 <div class="slds" style="margin-bottom:100px">
        <div id="header">
           Students Record
        </div>
         
        <br/>
        <br/>        
        <table>
            <tr>
                <td > <apex:inputText id="text-input-01" value="{!StudentName}" html-placeholder="Enter Student Name" /></td> 
                
                <td >
              
                             	<apex:selectList value="{!Year}" size="1"> 
                    				   <apex:selectOptions value="{!AcademicYear}"  />
          						</apex:selectList>

            </td>
             <!--   <td >   <apex:selectList value="{!School}" size="1"> 
                    				<apex:selectOptions value="{!SchoolName}" />
          						</apex:selectList></td> -->
               
                  <td >  <apex:commandButton value="Go!" action="{!search_method}"    /></td>   
            </tr>
        </table>
     <br/>
     <br/>
     
      <table class="slds-table slds-table--bordered profilelisting">
      
                <thead>
                    <tr class="slds-text-heading--label">
                       
                        <th scope="col" width="12%">
                           Studnet ID   </th>
                        <th scope="col"   width="12%"   >
                          Student Name
                      </th>
                      <th  scope="col" width="12%"  >
                           Academic Year
                      </th>
                        <th  scope="col" width="12%"  >
                          Class
                      </th>
                        <th scope="col" width="12%">
                           School   </th>
                        <th scope="col"   width="12%"   >
                          City
                      </th>
                      <th  scope="col" width="12%"  >
                          State
                      </th>
                       </tr>
                </thead>
                
                <tbody>    
                        
                     <apex:repeat value="{!StudDetail}" var="StDetail" >
                        <tr>
                            <td>  <apex:commandLink  action="{!StudPage}" style="text-align:center;">
                                {!StDetail.Student_Name__r.Name}
                                <apex:param name="StudId" value="{!StDetail.Student_Name__c}" assignTo="{!StudId}"/></apex:commandLink>                                            
                          
                            </td>
                           <td > {!StDetail.Student_Name__r.Student_First_Name__c} {!StDetail.Student_Name__r.Student_Last_Name__c}</td>
                       <td > {!StDetail.Year__c}</td>
                        <td > {!StDetail.Name}</td>     
                           <td > {!StDetail.School_Name__r.School_Name__c }</td>
                       <td > {!StDetail.Student_Name__r.City__c}</td>
                            <td > {!StDetail.Student_Name__r.State__c}</td>
                           </tr>
                            </apex:repeat>
                                       
                       </tbody>
                                              
        </table>
        
  
            
        </div>
    </apex:form>
    </html>
</apex:page>

VisualForce Page 2:
 
<apex:page controller="StudentProfileListViewTest" showHeader="true" sidebar="false" standardStylesheets="true" docType="html-5.0">
    
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" />
    <apex:includeScript value="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js" />
   
    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <apex:stylesheet value="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css"/>

    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<apex:form >
  
 <!-- REQUIRED SLDS WRAPPER -->
    <div class="slds" style="margin-bottom:100px;width:100%">
        <div id="header">
                     Student Profile Summary
         </div>
        <br/>       <!--LIST OUT ALL THE Students Academic Performance -->
  <apex:variable var="ctrcnt" value="{!1}"  />                    
  <apex:repeat value="{!Stud}" var="student">     
         
       
             <div id="card">
               <apex:outputPanel rendered="{!ctrcnt==1}" >
                 
                     
                   <div class="slds-card__body slds-text-align--center">
                        <div class="slds-tile">
                        <p class="slds-truncate">
               <b>Student Name:</b> {!studentrec.Student_First_Name__c} {!studentrec.Student_Last_Name__c}
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Student Class:</b> {!student.Name} <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Year: </b> {!student.Year__c}<br/>
               <b> Caste:</b> {!studentrec.Student_Caste__c} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b> Medium:</b> {!student.Medium_of_Instruction__c} <br/>
               </p>
               </div>
               
                </div>
                
            </apex:outputPanel>
           <apex:variable value="{!ctrcnt+1}" var="ctrcnt"/>  <!--increment-->
           </div>

<div  class="slds-card1" >
     <div class="slds-card__body">
         
        <table class="slds-table slds-table--bordered profilelisting">
      
                <thead>
                    <tr class="slds-text-heading--label">
                       
                        <th scope="col" width="12%">
                           Subject                        </th>
                        <th scope="col"   width="12%" class="slds-is-sortable"  >
                           Prior Exam
                      </th>
                      <th  scope="col" width="12%" class="slds-is-sortable" >
                           Final Exam
                      </th>
                       </tr>
                </thead>
                
                <tbody>    
                        
                        <apex:repeat value="{!student.Student_Scores__r}" var="cont">
                        <tr>
                                                                         
                           <td class="slds-cell-shrink">  {!cont.Subject_Name__c}</td>
                           <td class="slds-cell-shrink"> {!cont.Second_Exam_Marks__c}</td>
                       <td class="slds-cell-shrink"> {!cont.Final_Exam_Marks__c}</td>
                           </tr>
                            </apex:repeat>
                                       
                       </tbody>
                                              
        </table>
    </div>
   
        </div>

       </apex:repeat> 
       <br/>
       <br/>
          <div  class="slds-card3" >
     <div class="slds-card__body3"> 
   <div id="header1"> Student's Family Details  </div> 
        <table class="slds-table slds-table--bordered1 profilelisting1">
            <thead>
                    <tr class="slds-text-heading--label">
                       
                        <th scope="col" width="12%">
                       Family Member Name                        </th>
                        <th scope="col" width="12%" class="slds-is-sortable"  >
                           Relationship
                      </th>
                      <th  scope="col" width="12%" class="slds-is-sortable" >
                         Monthly Income
                      </th>
                        
                        <th scope="col" width="12%" class="slds-is-sortable"  >
                           Education Level
                      </th>
                      <th  scope="col" width="12%" class="slds-is-sortable" >
                        Occupation
                      </th>
                       </tr>
                </thead>
              <tbody>    
                        
                        <apex:repeat value="{!Family}" var="student">
                        <tr>
                                                                         
                           <td class="slds-cell-shrink">  {!student.Name}</td>
                           <td class="slds-cell-shrink"> {!student.Relationship_with_Student__c}</td>
                       <td class="slds-cell-shrink"> {!student.Monthly_Income__c}</td>
                             <td class="slds-cell-shrink"> {!student.Education_Level__c}</td>
                       <td class="slds-cell-shrink"> {!student.Occupation__c}</td>
                           </tr>
                            </apex:repeat>
                                       
                       </tbody>
     
   
       </table>
              </div></div>
        <div  class="slds-card2" >
     <div class="slds-card__body2"> 
   
              <div id="header1"> Counselling Parameters </div>
        <div id="Counselling" width="200px" class="tablecontainer">
        <table id="Counselling" class="slds-table slds-table--bordered profilelisting" cellpadding="3px !important" >
            <tr>
                <td>Child's Interest</td><td> {!studentcounsel.Childs_Interest__c} </td>
                <td >Parent's Interest</td><td> {!studentcounsel.Parents_Interest__c}</td>
                </tr><tr>
                <td>Role Model</td><td> {!studentcounsel.Role_Model__c}</td>
                 <td>Holland Code</td><td>{!studentcounsel.Holland_Code__c}</td>
                 </tr>
                 <tr>
                <td>Travel For Education </td><td> {!studentcounsel.Travel_For_Education__c}</td>
                    <td>Extra Curricular</td><td>{!studentcounsel.Extra_Curricular_Activities__c}</td>
</tr><tr>
                                     
                        <td>Family Understand Higer Ed Options</td><td> {!studentcounsel.Family_Understand_Hr_Ed_Options__c}</td>

                     <td>Highest Ed Level in Family</td><td> {!studentcounsel.Highest_Ed_Level_in_Family__c}</td>
</tr><tr>
                          <td>Family Funding Education Method</td><td> {!studentcounsel.Family_Funding_Education_Method__c}</td>

                              <td>Family Open to Meet</td><td> {!studentcounsel.Family_Open_to_meeting_to_understand_Ed__c}</td>
</tr><tr>
                                  <td>Relatives who can fund Education</td><td> {!studentcounsel.Relatives_who_can_fund_education__c}</td>
<td></td><td></td></tr>
                   
                               </table>    
                               </div>   
         </div></div>
        
       </div>  
    
</apex:form>
    </html>
</apex:page>

Thanks
Sivapriyaa M S