You need to sign in to do that
Don't have an account?
osaman
Putting a List of String in Page Reference Parameter
Hi,
I was wondering if we can pass in an array as a parameter and extract it on some other page. I know we can do that with a string as ApexPages.CurrentPage().getParameters().put('myVar', value) but what if we want to pass a list?
Does anyone have any workaround for this other than individually passing each value?
Thanks
You can also pass the list as parameter in URL but in the same way "ApexPages.CurrentPage().getParameters().put('myVar', value)". Now you need to manipulate the result according to your need.
If you want to send an array in URL and want to get it in array in the target class then I don't think you can do this. I have done this before because I have too many parameters to send in URL which may cause URL limit errors, so I created a temp object where I store all my data before redirecting to the new page. While redirecting to the new page I send the record Id in URL as parameter where I have stored my data.
In new page controller I again fetch the data from record Id and use it. Don't know this approach will help you or not.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thanks for your reply.
Since its a wizard, I am using same controller across my pages. Now, according to this source, getParameters() Map's return type is Map<String, String>. That means I can only pass in String and in order to pass a list, I'd have to go pass each element separately.
Any more thoughts?
Thanks
Suppose I need to send multiple values as parameter in URL. Let say
Name = Ankit
Role = Developer
There can be multiple ways to send this via URL
1) Append in URL separately like this https://...../apex/MyPage?Name=Ankit&Role=Developer..... and so on
2) I will create a temp Object with a text filed lets say "Myparam"
I will save my parameter values in that record as String like this MyParam = 'Name=Ankit,Role=Developer'. Then pass this record Id in URL https://...../apex/MyPage?MyRecord=xxxxxxxxxxxxxxx . In the target page controller fetch this record Id using "ApexPages.CurrentPage().getParameters().get('MyRecord') ;". Now fetch the record from data base and split it with the delimiter provided (in this case ',' ). You should go with this approach when you don't want to expose the parameter in URL or they too big to send via URL.
I hope this will help you
Thanks
Ankit Arora
Blog | Facebook | Blog Page