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
Sivasankari MuthuSivasankari Muthu 

How to get id from URL?

Hi,
I am having Two visualforce pages:
First Page: DisplayUniversities.vfp
 
<apex:page Controller="ILP_College_District_City" showHeader="false" 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="{!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:insert name="header">
<c:ILPCSMHEADER ></c:ILPCSMHEADER>
</apex:insert>
    <apex:form>
        <style>
        .center {
    	text-align: center;}
        </style>
        <br/>
        <br/>
        
    <table>
    <tr>
    	<td ><apex:inputText list="{!listOfDistrictName}" value="{!district}" html-placeholder="Enter District Name" /></td> 
        <td ><apex:inputText list="{!listOfCityName}" value="{!city}" html-placeholder="Enter City Name" /></td> 
    	<td ><apex:commandButton value="Go!" action="{!search_method}"/></td>
    </tr>
        </table>
    <!--</table>
        <table>
            <tr>
            <th>College Name</th>
            </tr>
        </table>
        <apex:repeat value="{!districts}" var="dis">
            <div class="center">
                <td>{!dis.College_Name__c}</td><br/>
            </div>
        </apex:repeat>-->
        
        <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlockTable value="{!districts}" var="dis">
        <apex:column >
        <apex:facet name="header">College Name</apex:facet>
            <!--<apex:outputField value="{!dis.College_Name__c}"/>-->
            <apex:commandLink action="{!Move}" >{!dis.College_Name__c}
            <apex:param name="collegeId" value="{!dis.id}" assignTo="{!collegeId}"/>
            </apex:commandLink>
        </apex:column>
        </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
              
    </html>
</apex:page>
The Output of first page:

User-added image

Controller : ILP_College_District_City
 
public class ILP_College_District_City {
ID qstr = System.currentPagereference().getParameters().get('collegeId');
public List<String> listOfDistrictName {get;set;}
public List<String> listOfCityName {get;set;}
public List<ILP_CSM_COLLEGES__c> districts {get;set;}  
public List<ILP_CSM_COLLEGES__c> cities{get;set;}
public List<ILP_CSM_COURSES_BY_COLLEGES__c> colleges{get;set;}
//public ILP_CSM_COURSES_BY_COLLEGES__c collegess;
public string district{get;set;}
public string city{get;set;}
public string collegeId{get;set;}
    public ILP_College_District_City()
    {
        listOfDistrictName = new List<String>();   
	for(ILP_CSM_COLLEGES__c districtName: [select id,District__c from ILP_CSM_COLLEGES__c ])
		listOfDistrictName.add(districtName.District__c);
        listOfCityName = new List<String>();   
	for(ILP_CSM_COLLEGES__c districtName: [select id,City_Town__c from ILP_CSM_COLLEGES__c ])
		listOfCityName.add(districtName.City_Town__c);
    }
    public LIST<ILP_CSM_COURSES_BY_COLLEGES__c> getColleges()
    {
        System.debug('qstr'+qstr);
       colleges = [Select Name, Course_Level__c, Degree_Conferred__c,College_UGC_Id__r.College_Name__c from ILP_CSM_COURSES_BY_COLLEGES__c where College_UGC_Id__c =: qstr];
    return colleges;
    }
    public void search_method()
    {
        //students = [select Student_First_Name__c, Student_Last_Name__c from ILP_CSM_Student_Profile__c where Student_First_Name__c =: student];
         if(!district.equals(''))
        	districts = [select College_Name__c from ILP_CSM_COLLEGES__c where District__c =: district];
        	
    	 if(!city.equals(''))
            //schools = [select id, Name,School_Name__c, Village_Name__c,District__c, State__c from Schools_Master__c where School_Name__c =: school];
    		districts = [select College_Name__c from ILP_CSM_COLLEGES__c where City_Town__c =: city];
    	
    }
    public PageReference Move()
    {
        String qstr = System.currentPagereference().getParameters().get('collegeId');
        System.debug('move'+qstr);
    //PageReference Page = new PageReference('/apex/StudentAcadpgTest?id='+qstr1);
    PageReference Page = new PageReference('/apex/ILP_College?id='+qstr);
    //colleges = [Select Name, Course_Level__c, Degree_Conferred__c,College_UGC_Id__r.College_Name__c from ILP_CSM_COURSES_BY_COLLEGES__c where College_UGC_Id__c =: qstr];
    Page.setRedirect(true);
    return Page;
    }
}
Once i click on the College name, It will redirect to second page with college id.
Second Page: ILP_College.vfp
This page is also using the same above controller. This page use the college id what in URL to show the data of that college. But this id is not entering into method (getColleges()) to query the college details.
<apex:page Controller="ILP_College_District_City" showHeader="false" sidebar="false" standardStylesheets="True" docType="html-5.0">
   <apex:form>
    <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlockTable value="{!colleges}" var="dis">
        <apex:column >
        <apex:facet name="header">College Name</apex:facet>
            <apex:outputField value="{!dis.Name}"/>
            <apex:outputField value="{!dis.Course_Level__c}"/>
            <apex:outputField value="{!dis.Degree_Conferred__c}"/>
            <apex:outputField value="{!dis.College_UGC_Id__r.College_Name__c}"/>
        </apex:column>
        </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form> 
</apex:page>
Output of second page:

User-added image

This second page is not showing the data from controller.

Please suggest solution.

Thanks
Sankari M
JeffreyStevensJeffreyStevens
In your controller - you need to get the parameter from the URL - like this...
 
string QIdStr = ApexPages.currentPage().getParameters().get('Id');