Forum Discussion
Hi peterlu,
Freemarker actually has a directive for testing whether a variable is a number, so you may want to explore that as an alternate to using attempt/recover. For example:
<#if test?is_number> ... </#if>
Reference materials available here:
http://freemarker.sourceforge.net/docs/ref_builtins_expert.html#ref_builtin_isType
The behavior you describe definitely sounds odd, but there'd probably need to be some additional investigation to determine what is the expected behavior. If you believe this is a bug, I'd suggest filing a case so that it can get on the Support team's radar and be tracked through resolution.
Hi AdminN,
I know that there is a is_number function. But I wont use it. Thank you for the suggestion anyway.
Use case: I want to get a custom query string value from url for pagination purpose. eg. http://...../?my-page-number=3
When I get this my-page-number from url, it will always be a string. I need to convert it into number.
But it is possible that url may be hacked by ?my-page-number=bar
My only intertest is why the "This widget cannot be displayed" only show up for non-admin users. I have been written so many custom components for lithium. And this question is alway bugging me. According to freemarker docs, attempt/recover looks like java try catch. So why Lithium show up this error message for users, not admins?
BTW, I am not talking about a string to number conversion here only. It is about the general attempt/recover.
Related Content
- 5 months ago
- 2 years ago
- 2 years ago