[xwiki-devs] Where to define new property types? Java vs. Wiki
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. Thanks, Marius
Hi Marius, While I agree it would make sense to be able to define new class properties type directly from the wiki, I also think that it shouldn't happen in AWM, which is an "optional" application and IMO shouldn't be needed for offering new types of data. In my opinion doing this would be a slippery slope where we start to make AWM more and more a required dependency for whoever wants to develop an application in XWiki. Does this make sense ? Jerome On 10/15/2012 12:21 PM, Marius Dumitru Florea wrote:
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.
Thanks, Marius _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Peace, —Jerome
2012/10/15 Marius Dumitru Florea <[email protected]>
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/xwik... 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 [email protected] 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
On 10/15/2012 06:21 AM, Marius Dumitru Florea wrote:
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.
If a property type makes sense, it should be available without using AWM, thus it should be a standard property type defined in Java. To introduce some components in the way properties are handled, I think that it might be enough to convert just the *MetaClass classes (from com.xpn.xwiki.objects.meta) into components, with com.xpn.xwiki.objects.meta.MetaClass updated to replace the static initialization with a component list lookup. Actual property classes are created by their corresponding *MetaClass, and actual properties are created by their corresponding *PropertyClass, so they don't have to be touched. -- Sergiu Dumitriu http://purl.org/net/sergiu/
On Tue, Oct 16, 2012 at 3:46 AM, Sergiu Dumitriu <[email protected]> wrote:
On 10/15/2012 06:21 AM, Marius Dumitru Florea wrote:
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.
If a property type makes sense, it should be available without using AWM, thus it should be a standard property type defined in Java.
To introduce some components in the way properties are handled, I think that it might be enough to convert just the *MetaClass classes (from com.xpn.xwiki.objects.meta) into components, with com.xpn.xwiki.objects.meta.MetaClass updated to replace the static initialization with a component list lookup. Actual property classes are created by their corresponding *MetaClass, and actual properties are created by their corresponding *PropertyClass, so they don't have to be touched.
+1 for introducing components for this. Once you have components it's easy to either use wiki component or introduce a special bridge to define new classes in the wiki.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Mon, Oct 22, 2012 at 9:58 AM, Thomas Mortagne <[email protected]> wrote:
On Tue, Oct 16, 2012 at 3:46 AM, Sergiu Dumitriu <[email protected]> wrote:
On 10/15/2012 06:21 AM, Marius Dumitru Florea wrote:
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.
If a property type makes sense, it should be available without using AWM, thus it should be a standard property type defined in Java.
To introduce some components in the way properties are handled, I think that it might be enough to convert just the *MetaClass classes (from com.xpn.xwiki.objects.meta) into components, with com.xpn.xwiki.objects.meta.MetaClass updated to replace the static initialization with a component list lookup. Actual property classes are created by their corresponding *MetaClass, and actual properties are created by their corresponding *PropertyClass, so they don't have to be touched.
+1 for introducing components for this.
Once you have components it's easy to either use wiki component or introduce a special bridge to define new classes in the wiki.
I'm going to push a branch with this in a few minutes and send a proposal. Thanks, Marius
-- Sergiu Dumitriu http://purl.org/net/sergiu/
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (5)
-
Jerome Velociter -
Ludovic Dubost -
Marius Dumitru Florea -
Sergiu Dumitriu -
Thomas Mortagne