+ Start a Discussion

How to Navigate Pages within site?

Hi friends,


I'm new to this tech.


I create 3 pages like page1, page2 and page3


in page 1 i've list of book details like book name and description,


if i click book name it redirect to page2. page 2 contains full information about book.


when i create a site , i done page 1 as home page. but it not redirect to page2


this is the url http://ebooksinfo-developer-edition.ap1.force.com/listbooks  



following is my code in home page


<apex:page standardStylesheets="false" showHeader="true" sidebar="false" standardController="Book__c" recordSetVar="Books" >
<apex:stylesheet value="{!URLFOR($Resource.Styles, 'styles.css')}" />
<apex:form >
<h1> Display Records </h1>
 <apex:dataTable value="{!Books}" var="bitem" rowClasses="odd,even" style="margin:10px 0px 0px 20px; border:1px red solid;" cellspacing="5">
     <apex:column headerValue="Book Name" >
     <apex:outputText value="{!bitem.Book_Name__c}"></apex:outputText>
     <apex:column headerValue="Price of the Book">
     <p align="right">
     <apex:outputText value="{!bitem.Price__c}"></apex:outputText></p>
     <apex:column headerValue="Stock Avilable">
     <p align="right">
     <apex:outputText value="{!bitem.Stock__c}"></apex:outputText>
     <!--  <apex:column headerValue="Modify Price">
     <apex:inputText value="{!bitem.Price__c}"></apex:inputText>
     <apex:column headerValue="Update">
     <apex:commandButton action="{!save}" value="Save" rendered="true"/>
     </apex:column> -->
 <apex:commandLink id="CC1" action="http://ebooksinfo-developer-edition.ap1.force.com/page2?id=00190000006KnVu" title="Link1" value="Link" />



if any mistake i done give me correct solution.


Thanks and regards

Cory CowgillCory Cowgill

If these are standard detail pages, you can use the following relative URL:


<a href="/{!bitem.Id}">{!bitem.Name}</a>


If these are Visualforce Pages, you can use the following relateive URL:


<a href="/apex/Page2?id={!bitem.Id}</a>


In addition, if you want to process these as actions you can set the navigation in your controller by returning and setting a ApexPages.PageRefrence class:


<apex:commandLink action="{!sendToPage2}" value="Page 2"/>


public ApexPages.PageReference sendToPage2()


     return new ApexPages.PageReference('/apex/Page2?id=' + someId);




Check out this guide on how to build custom naviagtion