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
priya bhawna shettypriya bhawna shetty 

page reference related in visualforce

hi guys
please help me out with this  requiment
1.i displayed list of opportunity names&related stagenames in visualforce development mode,so now i want to navigate to detail page of that particular opportunity name ,when i clicked on it.
heres my code.
please tell me how do i do this by using javascript or by command link

PAGE:
<apex:page controller="opportunitydisplaycon" id="thePage">
<apex:form >
<script>
function generatedjs(){
gotodetail();
</script>
        <apex:dataTable value="{!opportunity}" var="opp" id="theTable"
                        styleClass="tableClass">

                <apex:facet name="caption">opportunity Details</apex:facet>

                <apex:column >
               
                                       
                        <apex:facet name="header">opportunity Name</apex:facet>

                         <a rerender="commandlink1" href="javascript:generatedJs();">{!opp.name}</a>
                                           
                        <apex:commandLink action="{!gotodetail}" id="commnadlink1"/>
                       
                       

                </apex:column>

                <apex:column >

                        <apex:facet name="header">opportunity stage</apex:facet>

                        <apex:outputText value="{!opp.stagename}"/>

                </apex:column>

        </apex:dataTable>
       
</apex:form>
</apex:page>

CONTROLLER:
public class opportunitydisplaycon {

   public List<opportunity> opportunity;
   public List<opportunity> getopportunity()
   {

        opportunity = [select name,stagename from opportunity limit 10];

        return opportunity;

   }
   public PageReference gotodetail() {
        pageReference p=new pageReference('/'+'recordID');
        p.setredirect(true);
        return p;
       
    }

}
Vamsi KrishnaVamsi Krishna
Priya,
you dont need a controller action or javascript for this.. you can directly invoke the detail page with the link..

<apex:page controller="opportunitydisplaycon" id="thePage">

<apex:form >
        <apex:dataTable value="{!opportunity}" var="opp" id="theTable"   styleClass="tableClass">
                <apex:facet name="caption">opportunity Details</apex:facet>
                <apex:column >
                        <apex:facet name="header">opportunity Name</apex:facet>
                         <a href="/{!opp.Id}">{!opp.name}</a>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">opportunity stage</apex:facet>
                        <apex:outputText value="{!opp.stagename}"/>
                </apex:column>
        </apex:dataTable>     
</apex:form>

</apex:page>

CONTROLLER:
public class opportunitydisplaycon {

   public List<opportunity> opportunity;
   public List<opportunity> getopportunity()
   {

        opportunity = [select id,name,stagename from opportunity limit 10];

        return opportunity;

   }

}
priya bhawna shettypriya bhawna shetty
hi vamsi
many thanks
it worked....
Vamsi KrishnaVamsi Krishna
Hi Priya, if the answers helped you can you mark a best answer to close the question.