You need to sign in to do that
Don't have an account?
Anchor is getting appended to URL parameter on redirect
I'm working with a Visualforce page that has anchors in it. It's doing inputFile "stuff" and this requires a page refresh. So I force the page refresh with an anchor in the pageReference like this:
PageReference refreshPage = new PageReference('/apex/thePage?id=' + o.Id); refreshPage.setAnchor(tabNumber); refreshPage.setRedirect(true); return refreshPage ;
The code above works like a charm and allows me to go back to a jQuery tab on refresh of the page. My new URL after refresh is this: https://c.cs0.visual.force.com/apex/thePage?id=006T0000008O8mVIAS#tabs-1
The problem I'm having is with this code:
PageReference newPage; newPage = new PageReference('/apex/anotherPage?id=' + o.Id); newPage.setRedirect(true); return newPage;
With the above code I get this URL: https://c.cs0.visual.force.com/apex/anotherPage?id=006T0000008O8mVIAS%23tabs-1
And I get this error: "Id value 006T0000008O8mVIAS#tabs-1 is not valid for the Opportunity standard controller"
I've tried to set the anchor to null and blank. A debug on getAnchor shows nothing before the redirect. For starters, I don't see why the standard controller isn't parsing out the %23 as an anchor. And finally I don't see how the anchor is getting passed to the next page in the first case. Any ideas?
I've solved this with what I would consider a hack. I'll post it in a bit but wanted to see if anyone had some ideas. Thanks,
George
may this link will helps u
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_encodingUtil.htm
or in the vf page u can use urlencode property....
Hi,
You can also remove extra values apart from the id inside the controller by using replace method of string.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
That seems like a bug to me. Have you opened a support case?
"aballard", I agree as I think it's a bug. I thought I'd throw it up to the community first. But I'll create a support case now.
"kiran_mutturu" - I can't encode or decode anything. A system debug on Apexpages.currentPage().getAnchor() shows null. And I've also done this on the redirect: newPage.setAnchor('') and newPage.setAnchor(null) and the id still gets the anchor.
"Navatar_DbSup" - I did your solution as my first "hack" and that does work. I was hoping to find something more than a hack as I hoped that I was doing something wrong. I was parsing the id by splitting the id out with a "#" as the separator. Like I said it works but still a hack.
The hack that I'm using that works and is faster than splitting or parsing is this:
By following the "id" parameter with "id2", I should be ensuring that the anchor will never be between the two parameters. When I redirect, I get this URL:
https://c.cs0.visual.force.com/apex/anotherPage?id=006T0000008O8mVIAS&id2=006T0000008O8mVIAS%23tabs-1
So at least the standard controller gets the id correctly. If any users ask me about the id2 parameter, I'll refer them to this thread. I'll make a case now.
Thanks,
geosow
Thought I'd give an update. Just heard back from SFDC support and they want to do a GoToMeeting to review my code. Here's my reply:
Here's my page attachment (FirstPage4SFDC.page):
And here's the extension (FirstPage4SFDC.cls):
I'm dealing with the same issue. Did you find any solution?
Ohhh... one thing... I read that if you debug "refreshPage.getAnchor()", you get a NULL value, I think the problem here is that you need to reassigne the var:
Thanks!
This never got resolved. It's a bug but the support rep wanted me to buy partner premium support before he'd follow up on it. So the solution was implemented with the hack. I had my client create a ticket with their premium support and nobody can figure out the issue to start solving it. I'm sorry to see you're having the same issue but I'm happy to see you're experiencing the issue; at least I know it's not just me!