+ Start a Discussion
the_wolfthe_wolf 

CommandButton not work with URL rewriter as outputLink with $Page

Hi all,

 

in new feature URL rewriter to navigate correctly from one page to another, it need to use URLFOR function with $page variable. Example:

<apex:outputLink value="{!URLFOR($Page.myOtherPage)}" />

 

But i have this commandButton that not work with my site that have enabled URL rewriter ! It return "Site in Maintenence" after click this button, and not myPage!

 

This is the button:

<apex:commandButton action="{!search}" value=" " styleClass="trova" id="searchButton"/>

 

 

And here is the code in my controller:

public PageReference cerca() {
               
        PageReference acctPage = Page.myPage;
        acctPage.setRedirect(true);
                
        return acctPage;

     }

 

How to set good the apex:commandButton, as the outputLink with $Page variable?

 

Thanks in advance!

 

 

Aaron FiskeAaron Fiske

I can't seem to reproduce your problem. I have a (very) simple rewriter:

 

 

global List<PageReference> generateUrlFor(List<PageReference> mySalesforceUrls){
          List<PageReference> myFriendlyUrls = new List<PageReference>();
          for(PageReference mySalesforceUrl : mySalesforceUrls) {
              myFriendlyUrls.add(new PageReference(mySalesforceUrl.getUrl() + '?REWRITTEN=TRUE'));
          }
    return myFriendlyUrls;
    }

 

Using your commandbutton & controller code, I get redirected to /myPage?REWRITTEN=TRUE when I click the button.

 

Try adding debugging to the end of your rewriter to see what URLs it's actually generating, and then just straight copy & pasting those URLs to see if they're really valid.

 

saharisahari

Hi

 

Did you get any solution for this ? 

Any help is greatly appreciated.

 

Thanks