You need to sign in to do that
Don't have an account?
ActionFunction takes user to PageReference
I want to call an action method in a VF controller and have it return a PageReference that the user goes to (it's actually null, I'm going back to the same page) just like an apex:commandLink. But, I need to do it onChange of a selectOption. I'm using an actionFunction that does a rerender but it doesn't function the same as a page reload because of complex script and styles on the page.
So what I really want to do is the equivent of using apex:commandLink to call an actionMethod and go to the Page Reference returned but trigger it from onChange of a selectOption?
Anyone know how to do that? Basically load a new page based on a PageReference from an onChange rather than a rerender?
W
<apex:selectList value="{!selectedvalue}" multiselect="false" size="1" >
<apex:actionSupport event="onchange" action="{!actiononchange}" rerender="redirect_method_name"/>
<apex:selectOptions value="{!optionProductList}" />
</apex:selectList>
Use below code to reload page in VF controller method called via action support .
PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl());
pageRef.setRedirect(true);
return pageRef;
Or call a javascript method oncomplete of action Support with below code :
window.location.href = window.location.href;
On the PageReference, I don't believe I would want redirect. I believe redirect will reload the controller and I want the controller already in memory. But perhaps that could just be removed.
I thought about just resetting the location to the same location as in your last explain. I don't know if that will work but I might try it sometime.
Remove 'redirect_method_name' as it is not related to your code,it is used to load again any visualforce component by using its ID after action support completes.
Above examples of page reload will execute your controller again.What you can do is rerender the whole page by replacing 'redirect_method_name' with ID of any Visualforce component that contains all the page like Outpanel ID etc.
Thanks
Ajay
Maybe something with onComplete that will load the next revision of the page would be more like what we are trying to do.