You need to sign in to do that
Don't have an account?
VF
issue in constructor method
In my class i have a constructor here i am calling a method in the constructor so as to redirect to another Vf page.
Here is the code:
class:
public class MyClass
{
public MyClass(ApexPages.StandardController controller)
{
ShowDetails();
}
public PageReference ShowDetails()
{
return page.MyPage;
}
}
is there any thing wrong in the code.Help me out guyz
Thanks shaan
Hey
No navigation would occur because constructors return void. You can call you method from the action method of <apex:page> though.
Cheers,
Wes
Thanks for ur reply.
I know about the action method but would like to navigate using constructor.
can i navigate using a void method from one page to another???
Unfortunately not. Action methods that return pageReferences or URLFOR in an action attribute are your direct options.
Wes
Thanks again wes.
My problem is that i am opening a VF page when clicked on a VF tab.
In that page i am displaying the custom object details in the page.
Before the page is opened i am checking a condition .
The condition is :
if(objectList.size() >0)
{
display values..........
}
else
{
redirect to New page.....
}
is there any solution for this with u??
Hey
Ah I see your problem now;) I've done a very brief test and this compiles
action="{!IF(true,null,null)}"
I'm not sure if it will work though. Try changing it to suit your needs, eg.
action="{!IF(methodToCheckSize,null,ShowDetails)}"
Hope that works,
Wes
did you ever sloved it? i am also running into same issue.