ok, nevermind, I figured it out, you use the BaseClass methods addTextField, addNumberField, etc.. Dan -----Original Message----- From: dullfig Sent: Wednesday, August 03, 2016 8:33 AM To: [email protected] Subject: Re: [xwiki-users] How to get property data type in a somewhat related question, is it possible to add properties to a class from a script? (velocity, groovy, etc) Dan From: Marius Dumitru Florea [via XWiki] Sent: Wednesday, August 03, 2016 2:11 AM To: dullfig Subject: Re: How to get property data type On Wed, Aug 3, 2016 at 9:29 AM, Alexandru Cotiuga < [hidden email]> wrote:
Hello Dan,
To find out what is the data type of a field you need to get the its class with $field.class and depending on your needs, you can have something like: $field (1) $field.class (class java.lang.Integer) $field.class.name (java.lang.Integer) $field.class.simpleName (Integer)
If by "field" Dan means the property of an object attached to a wiki page #set ($field = $xwiki.getDocument('Blog.BlogIntroduction').getObject('Blog.BlogPostClass').getProperty('publishDate')) then the field type can be obtained from the XClass #set ($fieldType = $xwiki.getDocument('Blog.BlogPostClass').getxWikiClass().get('publishDate')) $fieldType.classType $fieldType.type This is documented at http://platform.xwiki.org/xwiki/bin/view/DevGuide/APIGuide#HAccessobjectsina... . Hope this helps, Marius
Hope this is what you need, Alex
On Wed, Aug 3, 2016 at 2:07 AM, dullfig <[hidden email]> wrote:
hello:
This seems like a simple question, but I looked through the API and couldn't igure it out. How do you get the data type of a field? is there a way to know from velocity if a field is a text field, number, date, etc?
Dan
-- View this message in context:
http://xwiki.475771.n2.nabble.com/How-to-get-property-data-type-tp7600548.ht...
Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [hidden email] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [hidden email] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [hidden email] http://lists.xwiki.org/mailman/listinfo/users -------------------------------------------------------------------------------- If you reply to this email, your message will be added to the discussion below: http://xwiki.475771.n2.nabble.com/How-to-get-property-data-type-tp7600548p76... To unsubscribe from How to get property data type, click here. NAML -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-property-data-type-tp7600548p76... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users