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
Ram_SF14Ram_SF14 

I am trying to redirect to a different page but it is actually showing a completely BLANK page

Hi All 

I am trying to redirect to a different page when clicked on a button in VF page, but it is actually showing a completely BLANK page. Can anyone please HELP ..!

Thanks
 
Varun SinghVarun Singh
Hi Ram
Try in this way

Controller
public with sharing class TestRedirectController 
{
    public String inputValue {get; set;}
 
    public TestRedirectController() 
    {
        inputValue = 'Hello';
    }
 
    public PageReference reloadPage() 
    {
        //return null;
        //return Page.TestRedirect;
 
        pageReference pr = Page.TestRedirect;
        pr.getParameters().put('id', '11123434');
        return pr;
    }
}
Page
<apex:page controller="TestRedirectController">
    <apex:form>
        <apex:inputText value="{!inputValue}"/>
        <apex:commandButton value="Reload Page" action="{!reloadPage}"/>
    </apex:form>
</apex:page>


 
Ram_SF14Ram_SF14
Hi Varun 

If you don't mind could you please explain 
 pr.getParameters().put('id', '11123434'); this bit in detail ?

Thanks
Varun SinghVarun Singh
Hi Ram,
pr.getParameters().put('id', '11123434'); 
this is  param value  we can pass vf page to controller
pr will return these value when we  used in vf page we have to use Id in controller 
public string id {get;set;}
then pass it from vf page
  <apex:param name="id" value="{!id}"/>

because  right now we are not passing parameter from vf  to  controller.So  we can set pr to reteun null
 
pageReference pr = Page.TestRedirect;
pr.setRedirect(true);
   return null;


 
Varun SinghVarun Singh
Ram_SF14Ram_SF14
I did the same but it is still coming as BLANK page. 
Varun SinghVarun Singh
Can you email me credtential then  i can check
?
varun@astreait.com
Sharad SoniSharad Soni
Hi Ram,

Controller

public class TestCont {

    public PageReference press() {
        return page.a;
    }
}

Default VF Page

<apex:page controller="TestCont" >
    <apex:form>
    <apex:commandButton value="Press" action="{!press}" />
    </apex:form>
</apex:page>

VF Page going to show on Button Press

<apex:page >
    <script>
    function f() {
            alert("Text");
        }
        </script>
    <apex:form>
        Hello
    <apex:inputCheckbox onclick="f()" />
        </apex:form>
</apex:page>

Please, Mark it best answer if you find it helpful.
Thanks
Ashutosh GurjarAshutosh Gurjar
Sharad you are right,..you deserve best answer but you should mention who taught you this technique,,,so i deserve best answer.
Thanks in advance