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

Redirect to New VF page for selected picklist value
Hi All,
I have picklist component with 5 (A,B,C,D,E) values. and my requirement is when user select A or B then it will redirect to the new VF page else it will remain on same page for other Values selection.
Thanks,
Anish
I have picklist component with 5 (A,B,C,D,E) values. and my requirement is when user select A or B then it will redirect to the new VF page else it will remain on same page for other Values selection.
Thanks,
Anish
Apex Class:
public class redirectonthebasisonpicklist
{
public list<selectoption>item{get;set;}
public string picklistvalue{get;set;}
public redirectonthebasisonpicklist()
{
item=new list<selectoption>();
item.add(new selectoption('None','---Select Options---'));
item.add(new selectoption('NewVFpage1','A)')); //NewVFpage1 your new page to redirect
item.add(new selectoption('NewVFpage2','B'));
item.add(new selectoption('SameVfpage','C')); // SameVfpage is your current VF page Name
item.add(new selectoption('SameVfpage','D'));
item.add(new selectoption('SameVfpage','E'));
}
public pagereference redirect()
{
PageReference pageRef= new PageReference('/apex/'+picklistvalue);
pageRef.setredirect(true);
return pageRef;
}
}
VF Page:
<apex:page controller="redirectonthebasisonpicklist" >
<apex:form >
<apex:selectList value="{!picklistvalue}" size="1" >
<apex:selectOptions value="{!item}"/>
<apex:actionSupport event="onchange" action="{!redirect}" />
</apex:selectList>
</apex:form>
</apex:page>