+ Start a Discussion
Julian Juez Alfaro 3Julian Juez Alfaro 3 

How to call from one visualforce page to another visualforce page

Hi all,

I have one VF tab displayed in a customer portal. The VF page (let's call it VFpage1) contains a link to another VF page (lets call it VFpage 2).

How should I write the link on VFpage1 the way that when clicking on it, the VF tab displays VFpage2 instead.

Needless to say, on VFpage2 page there should be another link that when clicked on, the VF tab should display VFpage1, just going back and forth between the 2 pages inside 1 tab (in the Customer Portal)

Requirement: we only use 1 VF tab.
I have tried with a href and with apex:outputLink, but nothing works.I don't know whether it is possible and if yes, how the syntax should be.

Thank you.
Julian
Maneesh Gupta 11Maneesh Gupta 11
Below should work I believe .. you need to write a method gotopage() on the click of the link 

PageReference gotoPage()
{
PageReference pr = Page.VFPage2;
pr.setRedirect(true);
return pr;
}
Julian Juez Alfaro 3Julian Juez Alfaro 3
Thank you Maneesh, but what do I write around it? Where / how do I write the text that should be clicked on?
I mean: when using a ref, the sintax is <a href="URL">Click here</a>
Where do I write "Click here" using your approach? Please note that I am not a developer myself. 

Thank you,
Julian
Maneesh Gupta 11Maneesh Gupta 11
You said both are VF pages.. then instead of using <a href> .. use can <apex:outputlink> to create he link and then <apex:outputlink onclick = "{!goto}">

Hope it helps
Julian Juez Alfaro 3Julian Juez Alfaro 3
Hi Maneesh,

I am very, very sorry... I still don't know how I should write the entire syntax, from begining to end.

I have also tried creating an APEX class with the content of your first answer but I get an error message when trying to save the class:
Error: Compile Error: unexpected token: 'PageReference' at line 1 column 0