6

I want the action function to be called when command button is clicked which calls an apex class.

The debug log is shoing everthing working fine but the page is not redirected.

<apex:form >
<apex:outputpanel>
<apex:actionFunction name="lnkNavClicked" action="{!openforms}" rerender="none" >
    <apex:param name="p1" assignTo="{!linkclicked}" value=""/>
<apex:actionFunction>
</apex:outputpanel>
<apex:outputpanel>
<table>
<tr>
<td>
<apex:commandButton value="PREVIOUS" action="{!Previous}" disabled="true"/>
<apex:commandButton value="NEXT" onclick="return lnkNavClicked('ContactDetailsPage');" />

</td>
</tr>
</table>
</apex:outputpanel>
</apex:form>

public pageReference openforms()
    {
        System.debug('## in openContactDetails');
        this.application = application;
        update (this.application);
        Id id = System.currentPageReference().getParameters().get('id');
        System.debug('## linkclicked' + linkclicked);
        PageReference pageRef = new PageReference('/' + linkclicked);
        pageRef.getParameters().put('id',id);

        System.debug('## pageRef' + pageRef);
        pageRef.setRedirect(true);
        System.debug('## pageRef.getRedirect()' + pageRef.getRedirect());

        return pageRef;

    }

I debugged this... In debug log.. Its giving all values... but not redirecting to that page ... what could be the issue

following are some parts of lines from debug log..

12:55:08.691 (691845000)|CODE_UNIT_STARTED|[EXTERNAL]|01pi0000003MRR3|NewCustomerAccountController invoke(openforms)
12:55:08.691 (691932000)|SYSTEM_MODE_ENTER|false
12:55:08.691 (691968000)|SYSTEM_METHOD_ENTRY|[157]|System.debug(ANY)
12:55:08.691 (691997000)|USER_DEBUG|[157]|DEBUG|## in openContactDetails
12:55:08.692 (692155000)|DML_BEGIN|[159]|Op:Update|Type:Application__c|Rows:1
12:55:08.771 (771775000)|USER_DEBUG|[161]|DEBUG|## linkclickedOAOAContactDetailsPage
12:55:08.772 (772077000)|USER_DEBUG|[165]|DEBUG|## pageRefSystem.PageReference[/ContactDetailsPage?id=a02i0000008LN7aAAG]
12:55:08.772 (772304000)|USER_DEBUG|[167]|DEBUG|## pageRef.getRedirect()true
12:55:08.772 (772316000)|SYSTEM_METHOD_EXIT|[167]|System.debug(ANY)
12:55:08.772 (772331000)|SYSTEM_MODE_EXIT|false
12:55:08.782 (782934000)|CODE_UNIT_FINISHED|OAOANewCustomerAccountController invoke(openforms)
12:55:08.783 (783885000)|VF_APEX_CALL|j_id38|{!openforms}|PageReference:/ContactDetailsPage?id=a02i0000008LN7aAAG
12:55:08.214 (785676000)|CUMULATIVE_LIMIT_USAGE
5
  • Try to remove rerender="none" from the action function. Commented Oct 24, 2013 at 12:27
  • 2
    I don't want to be too negative(again), but you may have a better time getting help if you pay some attention to your other questions. Improving them to the extend they get answered, or accepting one of the given answers. Commented Oct 24, 2013 at 12:28
  • 1
    mastOr... if i remove rerender='none' its passing null value to linkclicked
    – TestNS
    Commented Oct 24, 2013 at 12:46
  • What if you remove 'return' from onclick="return lnkNavClicked('ContactDetailsPage');"? Commented Oct 24, 2013 at 12:54
  • Had already tried by removing 'return' from onclick.. but this doesnt seem to be working..
    – TestNS
    Commented Oct 24, 2013 at 12:59

2 Answers 2

7

It won't work like this and here is why: Your action in the actionFunction returns a pagereference. But you also specify a rerender (Which you need to pass the parameter). This rerender prevents the page from redirecting because it rerenders a non-existing part of the page.

What you can do is not use an actionfunction but change the commandButton to:

<apex:commandButton action="" value="NEXT">
    <apex:param name="p1" assignTo="{!linkclicked}" value="ContactDetailsPage" />
</apex:commandButton>

Just another thought that just popped in my head about your original code you put in your question: You might try to put somewhere in your page:

<apex:outputPanel id="hiddenPannel" style="display:none;" />

And change the rerender="none" to rerender="hiddenPannel"

0

Just like you can write the apex command button <apex:commandButton> component must always be a child component of the <apex:form>:

<apex:form>
     <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
    </apex:pageBlockButtons>

<apex:form

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .