I am new to salesforce and trying to get this simple requirement working:
- Get a list of records on a visualforce page
- Have the Name field as hyperlink
- When user clicks on hyperlink then take them to detail page where details of that particular records are shown along with their child records
Here is my apex class to render the list view
public with sharing class proposalsController {
public List<Proposals__c> proposal {get;set;}
//In constructor
public ProposalsController(){
proposal = [Select id, CreatedDate, LastModifiedDate, Proposal_Id__c, Client_Name__c, Proposal_Type__c, Comments__c, Name from Proposals__c limit 1000];
}
}
Below is the code visualforce page
<table class="table table-hover" id="proposal-table">
<thead><tr><th>Proposal Name</th><th>Client Name</th><th>Proposal Type</th><th>Comments</th></tr></thead>
<tfoot><tr><th>Proposal Name</th><th>Client Name</th><th>Proposal Type</th><th>Comments</th></tr></tfoot>
<tbody>
<apex:repeat value="{!proposal}" var="pr">
<tr>
<td><apex:form >
<apex:commandLink action="{proposalDetail}" value="{!pr.Name}"/>
<apex:param name="id" value="{!pr.id}"/>
</apex:form>
</td>
<td>{!pr.Client_Name__c}</td><td>{!pr.Proposal_Type__c}</td><td>{!pr.Comments__c}</td></tr>
</apex:repeat>
</tbody>
</table>
This completes the first two parts of the requirement. I am not sure how to go about the last part.
Here is what I am trying to add my apex class
public string proposalDetail(){
String proposalId = ApexPages.currentPage().getParameters().get('id');
question = [Select id, CreatedDate from Question__c where proposal__c =: proposalId];
}
But I am not sure how to link to this to proposal_detail visualforce page that I have created to show the details.
I have searched and it seems redirect might be an option. What is the best way to achieve this?