What's wrong with this code?

public PageReference goodResponse() {
    PageReference fwdMessage = new PageReference(Page.TLResponsePage);
    return fwdMessage;

The TLResponsePage is there and everything. I'm calling this method from another method that returns another PageReference. Should all be good, but instead I get this error:

Constructor not defined: [System.PageReference].<Constructor>(System.PageReference)

Any ideas?

up vote 3 down vote accepted

Just change your declaration to:

PageReference redirect = Page.MyPage;

You can't pass a PageReference into the PageReference constructor, which you are trying to do.

  • So simple. Thank-you. And if I have some global variables in that method's class, should I be able to refer to them in TLResponsePage by their name? Because that returns this error: "Unknown property 'ParentClass.varName'",. – well-i-better-get-rolling Jan 28 '16 at 4:26
  • 1
    I'm not sure what you're getting at. Maybe worth a separate question? You can set parameters with redirect.getParameters().put(key, value). – Adrian Larson Jan 28 '16 at 4:32
  • Yeah, not really related. Thanks for your help. – well-i-better-get-rolling Jan 28 '16 at 4:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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