3

I have a button that redirects to a PDF page where the same controller fills in the information for both. To accomplish this I've been using a Command Button that returns a page reference of the PDF Page.

After a Recent update to the page, both that button and another button on the page have stopped working. The update was to a completely different section and different code on the page, and should not have interfered with either button or their methods in any way.

In the case of the redirect button it now returns a URL that seems to be the pages generated ID of the HTML Element with the value of the button appended.

Visualforce:

<div id="buttonPanel" class="panel panel-default">
                                    <form class="form-horizontal">
                                        <div class="panel-body">
                                            <apex:commandButton style="margin-left:2px;" styleClass="btn btn-primary btn-sm pull-right" disabled="false" value="Generate Quote" action="{!gotoPage2}"/>  
                                        </div>
                                        </form>
                                    </div>

Apex:

public PageReference gotoPage2(){
    String URL = '/apex/QuotePage';
    PageReference pageRef = new PageReference(URL);
    pageRef.setRedirect(false);
    return pageRef;
}

Starting URL:

https://[Instance].visual.force.com/apex/ConveniencePricing

Expected Redirect URL:

https://[Instance].visual.force.com/apex/QuotePage

Actual Redirect URL:

https://[Instance].visual.force.com/apex/ConveniencePricing?j_id0%3Aj_id30%3Aj_id237=Generate+Quote
  • 3
    Fyi you can do pageRef = Page.QuotePage – Adrian Larson Mar 15 '16 at 14:00
  • @AdrianLarson Thanks for the tip! Any thoughts on why the url is not working correctly? – Cody Beaner Mar 15 '16 at 14:23
  • Why are you calling setRedirect(false)? I don't understand the desired behavior. – Adrian Larson Mar 15 '16 at 14:28
  • @AdrianLarson to preserve the View State data for the PDF – Cody Beaner Mar 15 '16 at 14:31
  • 1
    @MichaelFleming that wasn't the case, I actually found the issue to be something I didn't even know would cause issues: two sets of <form> tags on a page. – Cody Beaner Apr 4 '16 at 15:43
1

So what I've discovered is that there were two tags on the web pag as a whole, and it caused a lot of weird issues with javascript and command buttons.

Removing one set of them fixed the issues completely.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.