+ Start a Discussion
James_DeanJames_Dean 

PageReference not working at all

This is my simple page and controller but it does not work at all........every time i click the submit button it refreshes the current page
---Page-----
<apex:page controller="MyController" tabStyle="Contact">
<apex:form >
 <apex:pageBlock>
  <apex:commandButton action="{!submit}" value="Export" id="BtnExport"/>              
 </apex:pageBlock>
</apex:form>
</apex:page>
---Controller-----
public class MyController { 
   public PageReference submit() {
        PageReference secondPage= new PageReference('www.google.com');
        secondPage.setRedirect(true);
        return secondPage;
    }
}
amar joshiamar joshi
PageReference secondPage= new PageReference('http://www.google.com');

try this its definitely works


James_DeanJames_Dean
no it doesn`t work...not even commandlink works with an ordinary url........why would this be?
amar joshiamar joshi
i have just copy and paste your code
 
and its working while changing http://www.google.com

i m wondering if u have another code with this so u may be stuck with other issues

please put all code


Message Edited by amar joshi on 09-30-2008 02:53 PM
James_DeanJames_Dean
Actually you were right........i had a problem in my code that gave no error but was incorrect and caused the function not to work.
djbakerman.ax666djbakerman.ax666
I'm having a similar problem, what was the code issue?