[MAGNOLIA-7864] ctx.getParameters()/ctx.getParameter('Param') returns only first occurance of paramater Created: 17/Aug/20 Updated: 19/Aug/20 Resolved: 19/Aug/20 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Bartosz Staryga | Assignee: | Unassigned |
| Resolution: | Not an issue | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| Date of First Response: |
| Description |
|
Having: ctx.getParameters() would return: *Hash (2) ctx.getParameter('Topic') would return: "typhoon" (String) We would expect to get all values.
|
| Comments |
| Comment by Roman Kovařík [ 17/Aug/20 ] |
|
Hi bstaryga you can use ctx.getParameterValues Hope that helps |
| Comment by Richard Gange [ 17/Aug/20 ] |
|
I think you could workaround that by using a comma. ?Topic=typhoon,hurricane&foo=bar |
| Comment by Roman Kovařík [ 19/Aug/20 ] |
<#list ctx.getParameterValues("test") as i>
- ${i}
</#list>
http://localhost:8080/magnoliaAuthor/travel.html?test=1&test=2 Output: - 1 - 2 |
| Comment by Bartosz Staryga [ 19/Aug/20 ] |
|
rkovarik Aaaa there you go i did not pass the param, but then if param is needed then it's not of use to me. Anyway, I already implemented a small freemarker function that returns for me array of all key value pairs. Also since no html nor url specs says that keys needs to be unique (actullay html5 mentiones they do not have to) ctx.getParameters()/ctx.getParameter('Param') should return all |
| Comment by Richard Gange [ 19/Aug/20 ] |
Paste it here for the community... |
| Comment by Bartosz Staryga [ 19/Aug/20 ] |
[#function function__getParameters] [#assign getParameters__parameters = []] [#assign getParameters__queryString = ctx.getRequest().getQueryString()!] [#if getParameters__queryString?has_content] [#assign getParameters__queryString = getParameters__queryString?split('&')] [#list getParameters__queryString] [#items as getParameters__queryString__item] [#assign getParameters__pair = getParameters__queryString__item?split('=')] [#assign getParameters__parameters += [\{'key': getParameters__pair[0]!, 'value': getParameters__pair[1]!}]] [/#items] [/#list] [/#if] [#return getParameters__parameters] [/#function] |