Thursday 12 February 2015

Override default String Type Value in Dialog : TypeHint CQ5

Hi Guys, 

Today i got to know how to override the default data type that is String when values are going to be store in JCR. As I found some related stuff in very old forum of CQ5 but it seems away from the search.

Use-Case : I am using my dialog with number of widgets which has xtype numberfield. So i suppose to store these in JCR as Long Type, but it take String as default type so my numbers are getting store in String type rather than Long type.

Solution is via using TypeHint. TypeHint  is one of the concept inside SlingPostServlet where it force the property to store its value with given Type. Below example demonstrate it :

1) Create a widget say num1 inside you dialog with xtype numberfield.  Same like below image :



2) Create a typehint node same as like the below image. Here the name property will be /nameofActualProp@TypeHint. 


3) Enter the values in dialog and submit it, you can view your property value as Long type in JCR rather than String.



Hope this will help

Thanks


No comments:

Post a Comment