You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2013/01/25 08:35:16 UTC

[jira] [Resolved] (SLING-2712) Update JavaDocs of ValueMap wrt primitive types

     [ https://issues.apache.org/jira/browse/SLING-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler resolved SLING-2712.
-------------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: JCR Resource 2.2.4)
                   API 2.3.2
         Assignee: Carsten Ziegeler
    
> Update JavaDocs of ValueMap wrt primitive types
> -----------------------------------------------
>
>                 Key: SLING-2712
>                 URL: https://issues.apache.org/jira/browse/SLING-2712
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.2.4
>            Reporter: Simone Tripodi
>            Assignee: Carsten Ziegeler
>             Fix For: API 2.3.2
>
>
> I have a {{Resource}} which has a property named {{releaseMonth}} which is of type {{long}}; then I have a simple {{NumberFormat}}
> {code}
> NumberFormat numberFormat = new DecimalFormat("00");
> {code}
> If I try to execute, in a JSP, the following code, to cast the {{releaseMonth}} property to the primitive {{long.class}}:
> {code}
> <%= numberFormat.format(properties.get("releaseMonth", long.class)) %>
> {code}
> It throws an exception:
> {code}
> Caused by: java.lang.IllegalArgumentException: Cannot format given
> Object as a Number
> at java.text.DecimalFormat.format(DecimalFormat.java:486)
> at java.text.Format.format(Format.java:140)
> at 
> org.apache.jsp.apps.gtunes.album.html_jsp._jspService(html_jsp.java:171)
> at 
> org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspB
> ase.java:70)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> at 
> org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(Js
> pServletWrapper.java:502)
> ... 68 more
> {code}
> If I use instead the primitive wrapper {{Long.class}}
> {code}
> <%= numberFormat.format(properties.get("releaseMonth", Long.class)) %>
> {code}
> everything works fine.
> Looks like that
> {code}
> properties.get("", long.class)
> {code}
> gets {{NULL}} back

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira