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

Page Redirect Issue



 I have two button on visual force page. One is apex command button and another is outputpanel with styleclass= btn.From apex command button I am calling execute method using action while in outputpanel I am calling execute method using actionFunction.In Execute, code create lead record and redirect to lead defualt list page.


It is working fine in case of apex command button but in case of outputpanel, code redirect the page on lead defualt page but it does not change url and also keeping page editor and component in page. Please guide.


Please help



<apex:page controller="VFJavaScriptDemo" >
<apex:form id="actionForm">
<apex:actionFunction id="executeId" name="executeData" action="{!execute}" reRender="dataForm"/>
<apex:form id="dataForm" >
<apex:inputText id="value" value="{!name}"/>
<apex:commandButton id="Save" value="Submit" action="{!execute}"/>
<apex:outputPanel onclick="checkJavaScript()" styleClass="btn">
Click Me
function checkJavaScript() {



public class VFJavaScriptDemo {
public String name { get; set;}

public PageReference execute() {
Lead l = new Lead(
lastname = 'VFJavaScript Testing',
company = 'sungard'

insert l;

PageReference pg = new PageReference('/00Q/o');

return pg;



Message Edited by Naishadh on 05-12-2009 05:43 AM
Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

no, really.

if you turn off developer mode,


both the edit window goes away and the redirect occurs correctly, nothing to do with the code.

All Answers

Please help!
Ron HessRon Hess
turn off Developer mode in your personal setup and it works fine.

I think you are calling Visualforce method from Javascript.  You might have to use actionFunction


Look at this example from docs:

I have not used it but try somethink like

<apex:actionFunction action:"{!execute}"
It could be that you have setup a reRender attribute for the actionFunction which could be preventing the redirect. Try removing that attribute.

Ron HessRon Hess

no, really.

if you turn off developer mode,


both the edit window goes away and the redirect occurs correctly, nothing to do with the code.

This was selected as the best answer
Thanks Ron!
Ron HessRon Hess

As a follow up i would like to point out that this page is best written with one apex : form tag


each form tag carries a seperate viewstate and this can make your page larger and slower, for no gain.


I think this is related to page redirect

I have a custom controller, and 2 visual force pages.

My page1 is  Inside account page layout. Page 1 has a button that post page2 

Page 2 posts inside the section of account. How do I post my page 2 to new page.


When I test with the following URL it works - page 2 is posted properly


When I test with following URL after adding to account page layout Page 2 is inside the account section

Here my code:



public with sharing class MytestController {

  private final Account stdAcct;


  public PageReference EditList(){

  //return page.MytestControllerPage2;

    PageReference editList = Page.MytestControllerPage2;



    return editList;



  public MytestController(ApexPages.StandardController stdcontroller){

    this.stdAcct =  [select id, name, BillingCity from Account   where id = :ApexPages.currentPage().getParameters().get('id')];






Page1 - added to account page layout 


<apex:page standardcontroller="Account" extensions="MytestController" sidebar="false" showheader="false" standardStylesheets="true">

<apex:pageBlock ><b>Account Name: </b><apex:outputText value="{!account.Name}" rendered="true"/>

<b> City: </b><apex:outputText value="{!account.BillingCity}" rendered="true"/>

<b> Market Name: </b><apex:outputText value="{!account.Market_Name__r.Name}" rendered="true"/>


<apex:form > <apex:pageBlock >

<apex:pageBlockButtons location="top">

<apex:commandButton action="{!EditList}" value="Post another page" status="status" />


</apex:pageBlock> </apex:form>


 Page2 - post from with button click on page1

<apex:page standardcontroller="Account" extensions="MytestController" sidebar="true" showHeader="true" standardStylesheets="true">

<!-- Begin Default Content REMOVE THIS -->


This is your new Page

<!-- End Default Content REMOVE THIS -->


 I tried using commandLink instead of Commandbutton and used target="_blank"  But the page does not display header and sidebar. 

NOTE: My page 1 has showHeader="false" Page 2 has showHeader="true"


I turned off DevelpmentMode in user setting.


Any suggestions?