You need to sign in to do that
Don't have an account?
PageReference not redirecting if within reRendered panel
Cheers!
I have a commandButton which calls an action that returns a PageReference. It works in one part of the page but not another. Here's the example:
I've got an page divided into left and right table columns. On the left, as standard list of objects. For this example I've used Contacts. Each row has a commandLink which reRenders (Ajax) the right hand side to reveal a form. The form contains a commandButton that calls an action which returns a Page redirect. But it doesn't work.
If I move the form to the bottom of the page, outside of all the action, it works fine.
What should I understand better about returning a PageReference?
Here's the VF page:
<apex:page standardController="Contact" extensions="ajaxPageRefIssueExt" recordSetVar="myContacts" sidebar="false" id="thisPage"> <table><tr valign="top"> <!-- here's my left-hand side --> <td width="600px"><apex:form > <apex:pageBlock > <apex:pageBlockTable value="{!myContacts}" var="c" rows="2"> <apex:column value="{!c.Name}"/> <apex:column > <apex:commandLink reRender="thisPage:aForm" status="aFormStatus"> Show Form... <apex:param name="contactId" value="{!c.Id}"/> </apex:commandLink> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form></td> <!-- and now my right-hand side --> <td> <apex:actionStatus startText="Getting a Form..." stopText="" id="aFormStatus"></apex:actionStatus> <apex:outputPanel id="aForm"> <apex:outputPanel rendered="{!NOT(ISNULL(contactId))}"> Uh oh...if this is reRendered by an Ajax call, this commandButton page redirect gets lost!? <apex:form ><apex:commandButton action="{!takeAction}" value="Submit..."/></apex:form> </apex:outputPanel> </apex:outputPanel> </td></tr></table> But it works fine down here... <apex:form ><apex:commandButton action="{!takeAction}" value="Submit..."/></apex:form> </apex:page>
and my extension class:
public class ajaxPageRefIssueExt { public ajaxPageRefIssueExt(ApexPages.StandardSetController controller) { } public String getContactId() { return System.currentPageReference().getParameters().get('contactId'); } public PageReference takeAction() { PageReference p = Page.ajaxPageRefIssueB; p.setRedirect(true); return p; } }