2

I'm using the following Visualforce code to send multiple parameters (including a returl) to a controller.

<apex:outputLink target="_blank"  styleClass="btn addToBtn2" 
value="/apex/NewScholarRequest?SiteID={!selectedProgram}?returl=/apex/be1_Attendance{!URLENCODE('?cy='+selectedCycle+'&di='+selectedDistrict+'&si='+selectedProgram)}">
New Scholar Request
</apex:outputLink>  

When I try to get the result in the controller constructor, I get:

tmp =  apexpages.currentpage().getparameters().get('siteID');

I get this result:

siteID=a0Z00000001BwnWEAS?returl=/apex/be1_Attendance?cy=a0J00000000hIKOEA2&di=a0K00000000dtALEAY&si=a0Z00000001BwnWEAS

That's the whole set of parameters, not just the first one. Why don't they get split up? Do I need to individually URLENCODE each parameter after the first?

2
  • 2
    I see 2 '?' try /apex/NewScholarRequest?SiteID={!selectedProgram}&returl=/apex/be1_Attendance....... Ideally I would use <apex:param> to pass parameters to the controller than this URL hack way, but thats your choice
    – Rao
    Commented Feb 17, 2016 at 22:46
  • I may well give the <apex:param> method a try. It certainly looks clearer than what I came up with.
    – Jagular
    Commented Feb 18, 2016 at 4:35

1 Answer 1

3

The URLENCODE call will encode the ? and & delimiters whereas you really need to just encode each parameter.

One way to do that is:

"/apex/be1_Attendance?cy={!URLENCODE(selectedCycle)}&di={!URLENCODE(selectedDistrict)}&si={!URLENCODE(selectedProgram)}"
1
  • Nice catch @KeithC!
    – Adrian Larson
    Commented Feb 18, 2016 at 2:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .