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
Sarvesh PrajapatiSarvesh Prajapati 

Visual force page not working

Hi,

I have created a visual force page. There are two objects Job Application and Candidate.
I'm displaying the name of Job Application in VF Page. When a name is clicked it should display candidate's first name, but its not displaying. Here is the code I have written.

VF Page
<apex:page controller="D_Controller">
 <apex:form >
  <apex:datalist value="{!JA}" var="item"> 
    <apex:commandLink action="{!JAclicked}" rerender="CandidateDetails">
      <apex:outputtext value="{!item.Name__c}" />
     <apex:param name="id" value="{!item.id}" assignTo="{!selectedCandidate}"/>
    </apex:commandLink>
  </apex:datalist>
 </apex:form>
 <apex:outputPanel id="CandidateDetails">
  <apex:repeat value="{!CandidateInfo}" var="item">
   <p>Custom Control Demo "{!item.First_Name__c}" </p>
  </apex:repeat>
 </apex:outputPanel>
</apex:page>

Controller
public class D_Controller 
{
 public id selectedCandidate{get;set;}
 public list<Candidate__c> CandidateInfo{get;set;}
 public list<Job_Application__c> getJA()
 {
   return [select Name__c, Position__c, Candidate__c from Job_Application__c limit 5];
 }
 public void JAclicked()
 {
  CandidateInfo = [select First_Name__c, Last_Name__c from Candidate__c where ID = :selectedCandidate] ;
 }
}


Please let me know hwat should I modify
Best Answer chosen by Sarvesh Prajapati
sfdc_Devlsfdc_Devl
Hi Sarvesh,

The parameter you are passing to the controller should be the candidate Id, not the Job Application Id.

VF Page
<apex:page controller="D_Controller">
 <apex:form >
  <apex:datalist value="{!JA}" var="item"> 
    <apex:commandLink action="{!JAclicked}" rerender="CandidateDetails">
      <apex:outputtext value="{!item.Name__c}" />
     <apex:param name="id" value="{!item.candidate__c}" assignTo="{!selectedCandidate}"/>
    </apex:commandLink>
  </apex:datalist>
 </apex:form>
 <apex:outputPanel id="CandidateDetails">
  <apex:repeat value="{!CandidateInfo}" var="item">
   <p>Custom Control Demo "{!item.First_Name__c}" </p>
  </apex:repeat>
 </apex:outputPanel>
</apex:page>

Change the item.Id to item.candidate__c.

Thanks
Ramya

All Answers

Mahesh DMahesh D
Hi Sarvesh,

You have use the below code to open the record:
<apex:outputLink value="{! URLFOR($Action.Job_Application__c.View, item.Id)}"> {! item.name} </apex:outputLink>

Please do let me know if it helps you.

Regards,
Mahesh
sfdc_Devlsfdc_Devl
Hi Sarvesh,

The parameter you are passing to the controller should be the candidate Id, not the Job Application Id.

VF Page
<apex:page controller="D_Controller">
 <apex:form >
  <apex:datalist value="{!JA}" var="item"> 
    <apex:commandLink action="{!JAclicked}" rerender="CandidateDetails">
      <apex:outputtext value="{!item.Name__c}" />
     <apex:param name="id" value="{!item.candidate__c}" assignTo="{!selectedCandidate}"/>
    </apex:commandLink>
  </apex:datalist>
 </apex:form>
 <apex:outputPanel id="CandidateDetails">
  <apex:repeat value="{!CandidateInfo}" var="item">
   <p>Custom Control Demo "{!item.First_Name__c}" </p>
  </apex:repeat>
 </apex:outputPanel>
</apex:page>

Change the item.Id to item.candidate__c.

Thanks
Ramya
This was selected as the best answer
Sarvesh PrajapatiSarvesh Prajapati
It worked. Thanks a lot