You need to sign in to do that
Don't have an account?

Apex page action - redirect or not redirect to the Insufficient Privileges page after checking a condition
Hi all,
I've a VF page and its controller,
I've used page action as below
<apex:page action="{!validateUser}"
in my controller i've a method like this
public pageReference validateUser(){
if(someconditionTrue)
PageReference errorPage = new PageReference('apex/ErrorPage');
errorPage.setRedirect(true);
return errorPage;
}
else{
//I need to stay in this page.
}
I'm not sure sure how to code for stay in this page, because this page is always recursively called.
I've a VF page and its controller,
I've used page action as below
<apex:page action="{!validateUser}"
in my controller i've a method like this
public pageReference validateUser(){
if(someconditionTrue)
PageReference errorPage = new PageReference('apex/ErrorPage');
errorPage.setRedirect(true);
return errorPage;
}
else{
//I need to stay in this page.
}
I'm not sure sure how to code for stay in this page, because this page is always recursively called.
Since you want to redirect to current page so no need to return anything , IF you give return null, the page will be in the same page, Hope this what you want .
Thanks,
Shiva
All Answers
Find the below code , That might helps you.
public pageReference validateUser(){
if(True){
PageReference errorPage = new PageReference('/apex/ErrorPage');
errorPage.setRedirect(true);
return errorPage;
}
else{
return null;
//I need to stay in this page.
}
}
Thanks,
Shiva
Any idea?
Since you want to redirect to current page so no need to return anything , IF you give return null, the page will be in the same page, Hope this what you want .
Thanks,
Shiva
Can i call like <apex:page action="{!commonClass.validateUser}"