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
Aki99Aki99 

Get the id of a row in a table and passit to next page

Hi all,

I am tring to develop an VF PAge which shows a list of books in pageblocktable.

Each row shows the data for a book record.

I want to get to the next page(the detail page) for the book selected by clicking on the command button in its row.

How to get that id of the selected book among all the idds in the table.

One idea is by using wrapper class but i am a newbie and don't know how to do this using that

Thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
vbsvbs

Try embedding an apex:outputLink component within a apex:column in the pageBlockTable. The value for the outputlink can be setup to the detail page of the custom object using URLFOR function see a snippet below:

<apex:pageBlockTable value="{!customObjectListVariable}" var="custom">
    <apex:column>
        <apex:outputLink value="{!URLFOR($Action.Custom_Object__c.view, Custom_Object__c.id}">{!custom.Name}</apex:outputLink>
    </apex:column>
....further colunms as required...... </apex:pageBlockTable>

 This will display a hyperlink for first column as the name of the custom object record and will drill down to the detail page of the object. the outputlink can be changed to a command button as desired.

All Answers

vbsvbs

Try embedding an apex:outputLink component within a apex:column in the pageBlockTable. The value for the outputlink can be setup to the detail page of the custom object using URLFOR function see a snippet below:

<apex:pageBlockTable value="{!customObjectListVariable}" var="custom">
    <apex:column>
        <apex:outputLink value="{!URLFOR($Action.Custom_Object__c.view, Custom_Object__c.id}">{!custom.Name}</apex:outputLink>
    </apex:column>
....further colunms as required...... </apex:pageBlockTable>

 This will display a hyperlink for first column as the name of the custom object record and will drill down to the detail page of the object. the outputlink can be changed to a command button as desired.

This was selected as the best answer
Aki99Aki99

Thankyou for your relpy vbsit helped a lot in solving my problem

Here's what how i've done it

With the output link i added a param for sending the current row id as:

 

<apex:outputlink value="/apex/Page17"> Custom Link <apex:param name="msg" value="{!nov.id}"/> </apex:outputlink>

 

Here the value of the param tag is the variable for the standard controller and I've accessed it's id field and passed that id to the next page and recieved ther by using

 

public string getval = System.currentPageReference().getParameters().get('msg');

 

And by so each row in my table can be clicked to reach to the next page containing its detail part.