2012/10/15 Marius Dumitru Florea <mariusdumitru.florea(a)xwiki.com>
Hi devs,
I'd like to extend the set of property types available in the AWM
class editor (the field palette) and I'm not sure where is the best
place to do this: in the Java code (oldcore) or in the wiki. I prefer
the wiki. Let me explain.
We recently added two new property types in the oldcore: email and
page. If you look at these two you'll see that email is just a string
property with a default validation regexp and page is just a dblist
property.
The AWM class editor has a system that lets you define property
'templates' in the wiki. To define the email property type I could do
this:
* create AppWithinMinutes.Email xclass with a single String property
(the 'template')
* set the validation regexp to match an email address (but I can set
other meta properties as well with *default* values)
* add an object of type AppWithinMinutes.FormFieldClass to
AppWithinMinutes.Email to specify (among other things) the list of
meta properties that should be visible in the class editor. For
instance, I'd like to hide the validation regexp.
At this point the AWM class editor will detect the email property type
and list it in the field palette and you can add it to your class. The
only problem is that when editing the class back the editor doesn't
have yet a way to determine what was the template used to add the
property so it uses the default one, the one for the String property
in this case.
So my question is: do you think it's good to be able to define new
property types from the wiki (e.g. Image, Attachment, Color, etc.) or
should they all be written in Java? If the answer is Wiki, then I'll
think of a way to store the reference to the property template so that
the AWM class editor can edit back using the right template.
Note that it crossed my mind to define a property type component that
can be implemented both from Java and from the wiki but transforming
the oldcore code that handles objects/properties into components is
very difficult.
This is of course what it should be. I don't think it's that hard though to
transform property classes into components, as this could be done without
changing anything from what the API of a property class is.
The only thing we want is to make it a component so that they are detected
automatically when starting XWiki. This happens currently in this class:
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwi…
where the list of properties is currently held in the form of classes that
derive from PropertyMetaClass.
It would be great to be able to define a new type in the wiki, but this
needs to end up as being something known by the core, and it might be
complicated because it requires 2 classes. The MetaClass and the Class
itself.
We discussed at some point that an application developped with AWM should
not require AWM to be installed to run. Right now this is not the case as
there are many includes of AWM code.
Ludovic
Thanks,
Marius
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
--
Ludovic Dubost
Founder and CEO
Blog:
http://blog.ludovic.org/
XWiki:
http://www.xwiki.com
Skype: ldubost GTalk: ldubost