I need to add a link to a VF page which opens the current page with an additional parameter (to allow an embedded VF page to redirect to itself as a non-embedded page). I have this, which works:
<apex:commandLink action="{!URLFOR('/apex/ListPage', id, [id=id, fullpage='1'])}"
value="Full List" />
This works fine, but I don't want the hardcoded page name. I've tried $CurrentPage
("Incorrect Argument type for function URLFOR"), $CurrentPage.url
("Invalid target parameter for function URLFOR), and even $CurrentPage.geturl
("Field getUrl does not exist", which proves that $CurrentPage.url
refers to something). $CurrentPage.name
compiles (I can save the page) but clicking the resulting link gives the error, "Formula Expression is required on the action attributes."
The other option that works is $Apex.ListPage
, but while it's not a string, it's still specific to the page name; I'd prefer something that would work in any page without edits. Possible?
aside: I'm passing the id as second param, but it was being ignored, so I added it to the extra param array, and it works fine. Not sure why that's needed, but it's working.
commandLink / commandButton
"side effects" should be OK and more forgiving ;). Another option might be to use embedded<apex:param>
s (don't make the link a self-closing tag){!URLFOR('/apex/' + $CurrentPage.Name, ...)}
?'/apex/'
did the trick. Accepted.