[xwiki-devs] XWiki Classes and Properties
Hello all, I went through the TodoClass tutorial and found it useful. I have a question regarding this functionality. Are these classes or the values of the properties for its instances saved in any table in the Xwiki database? Say, we use Classes and Objects to create a form that the user needs to create a document. Will the form values be saved in a database? How can we access the values of any instance of the created class? Also, how do we Delete a property from a Class definition? (If added by mistake while creating the class) Thanks for all help
Hello, by default, Classes aren't stored in any specific table but are stored as XML with the document... You can trigger an option called UseClassesTable or something like that which will make classes be stored in tables using the hibernate mapping defined by XWIki (tables xwikiclasses and xwikiclassesprop)... You can even provide your custom mapping... Anyway, this is not important because the class is the data structure and what you certainly need is to keep objects and property values. The objects are stored in the XWIkiObjects table and properties in the XWikiProperties table using objectID as external key and also in the specific XWikiTypeTable (XWikiStrings, XWikilongs etc...) depending on the type of the property. Concerning the deletion of properties, it doesn't exist yet because it is not so simple... But I'm currently working on a solution for that... I should propose a demo of it very soon... For the time being, this is not really easy because you have to go in the XWikiDoc table and modify the XWD_CLASS_XML to remove the unwanted field... Then you have also to find all the objects you created for this class and remove the unwanted fields... regards Pascal On 4/15/08, Kamna Jain <[email protected]> wrote:
Hello all,
I went through the TodoClass tutorial and found it useful. I have a question regarding this functionality. Are these classes or the values of the properties for its instances saved in any table in the Xwiki database? Say, we use Classes and Objects to create a form that the user needs to create a document. Will the form values be saved in a database? How can we access the values of any instance of the created class?
Also, how do we Delete a property from a Class definition? (If added by mistake while creating the class)
Thanks for all help _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Pascal, Thannks for the detailed explanation! Pascal Voitot wrote:
Hello, by default, Classes aren't stored in any specific table but are stored as XML with the document... You can trigger an option called UseClassesTable or something like that which will make classes be stored in tables using the hibernate mapping defined by XWIki (tables xwikiclasses and xwikiclassesprop)... You can even provide your custom mapping...
Anyway, this is not important because the class is the data structure and what you certainly need is to keep objects and property values. The objects are stored in the XWIkiObjects table and properties in the XWikiProperties table using objectID as external key and also in the specific XWikiTypeTable (XWikiStrings, XWikilongs etc...) depending on the type of the property.
Please, what is the so called UseClassesTable option intended for?
Concerning the deletion of properties, it doesn't exist yet because it is not so simple... But I'm currently working on a solution for that... I should propose a demo of it very soon...
These are great news! It is frequent to make a mistake as Kammy stated. And event more frequent is that a group changes its mind about the design of a given class.
For the time being, this is not really easy because you have to go in the XWikiDoc table and modify the XWD_CLASS_XML to remove the unwanted field... Then you have also to find all the objects you created for this class and remove the unwanted fields...
regards Pascal
There is still a Kamy's question left: "How can we access the values of any instance of the created class?" It may seem simple, but I and others are having a hard time trying to access and show these values. For instance, see this... http://tinyurl.com/3f44gm Please, could you elaborate your answer in that sense? Could it be advisable to add an example about how to access properties values in a given object to the FAQ tutorial? Perhaps how to retrieve all questions with a given string in question property. There is a FAQs entry about this (http://tinyurl.com/6rgm8h). I am sure this is enough for programmers, but it is a bit "conceptually dense" for non-programmers like me! As usually an example would help. Thanks for your help, Ricardo
On 4/15/08, Kamna Jain <[email protected]> wrote:
Hello all,
I went through the TodoClass tutorial and found it useful. I have a question regarding this functionality. Are these classes or the values of the properties for its instances saved in any table in the Xwiki database? Say, we use Classes and Objects to create a form that the user needs to create a document. Will the form values be saved in a database? How can we access the values of any instance of the created class?
Also, how do we Delete a property from a Class definition? (If added by mistake while creating the class)
Thanks for all help _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ricardo Rodríguez Your EPEC Network ICT Team
Hello, the option is the boolean "xwiki.store.hibernate.useclasstables" to put in the config... sorry if I don't answer quickly but I'm quite busy and I can't answer in a serious manner just now... Anyway, if it can help you, I think you should read this tuto: http://www.theserverside.com/tt/articles/article.tss?l=XWiki Even if I know a bit the class design, I'm not an expert yet :) But $xwiki.search seems not to return Object[] but Collection[] only with properties Name, ClassName and Number... Don't know why exactly but I will look at it... So something like this seems to work for me... you retrieve the doc and then the object and then you get our Object :) #set($query="from BaseObject obj where obj.className ='Contacts.ContactClass'") #set($results=$xwiki.search($query, 10, 0)) #foreach ($item in $results) #set($myObject = $xwiki.getDocument($item.Name).getObject($item.ClassName, $item.Number)) $myObject.get("firstname") | $myObject.get("surname") | $myObject.get("phone1") #end surname Maybe somebody could tell if there is something quicker? br Pascal On Tue, Apr 15, 2008 at 9:39 AM, [Ricardo Rodriguez] Your EPEC Network ICT Team <[email protected]> wrote:
Hi Pascal,
Thannks for the detailed explanation!
Pascal Voitot wrote:
Hello, by default, Classes aren't stored in any specific table but are stored as XML with the document... You can trigger an option called UseClassesTable or something like that which will make classes be stored in tables using the hibernate mapping defined by XWIki (tables xwikiclasses and xwikiclassesprop)... You can even provide your custom mapping...
Anyway, this is not important because the class is the data structure and what you certainly need is to keep objects and property values. The objects are stored in the XWIkiObjects table and properties in the XWikiProperties table using objectID as external key and also in the specific XWikiTypeTable (XWikiStrings, XWikilongs etc...) depending on the type of the property.
Please, what is the so called UseClassesTable option intended for?
Concerning the deletion of properties, it doesn't exist yet because it is not so simple... But I'm currently working on a solution for that... I should propose a demo of it very soon...
These are great news! It is frequent to make a mistake as Kammy stated. And event more frequent is that a group changes its mind about the design of a given class.
For the time being, this is not really easy because you have to go in the XWikiDoc table and modify the XWD_CLASS_XML to remove the unwanted field... Then you have also to find all the objects you created for this class and remove the unwanted fields...
regards Pascal
There is still a Kamy's question left: "How can we access the values of any instance of the created class?" It may seem simple, but I and others are having a hard time trying to access and show these values. For instance, see this...
Please, could you elaborate your answer in that sense? Could it be advisable to add an example about how to access properties values in a given object to the FAQ tutorial? Perhaps how to retrieve all questions with a given string in question property.
There is a FAQs entry about this (http://tinyurl.com/6rgm8h). I am sure this is enough for programmers, but it is a bit "conceptually dense" for non-programmers like me! As usually an example would help.
Thanks for your help,
Ricardo
On 4/15/08, Kamna Jain <[email protected]> wrote:
Hello all,
I went through the TodoClass tutorial and found it useful. I have a question regarding this functionality. Are these classes or the values of the properties for its instances saved in any table in the Xwiki database? Say, we use Classes and Objects to create a form that the user needs to create a document. Will the form values be saved in a database? How can we access the values of any instance of the created class?
Also, how do we Delete a property from a Class definition? (If added by mistake while creating the class)
Thanks for all help _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Ricardo Rodríguez Your EPEC Network ICT Team
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Thanks, Pascal, Pascal Voitot wrote:
Hello,
the option is the boolean "xwiki.store.hibernate.useclasstables" to put in the config...
sorry if I don't answer quickly but I'm quite busy and I can't answer in a serious manner just now... Anyway, if it can help you, I think you should read this tuto: http://www.theserverside.com/tt/articles/article.tss?l=XWiki
I think I have to read it a hundred time more :-) at least...
Even if I know a bit the class design, I'm not an expert yet :) But $xwiki.search seems not to return Object[] but Collection[] only with properties Name, ClassName and Number... Don't know why exactly but I will look at it...
So something like this seems to work for me... you retrieve the doc and then the object and then you get our Object :)
#set($query="from BaseObject obj where obj.className ='Contacts.ContactClass'") #set($results=$xwiki.search($query, 10, 0)) #foreach ($item in $results) #set($myObject = $xwiki.getDocument($item.Name).getObject($item.ClassName, $item.Number)) $myObject.get("firstname") | $myObject.get("surname") | $myObject.get("phone1") #end surname
I will follow this idea to see if I am able to understand how the mechanism does work! Vincent explanation is The Server Side must be enough. The point is to read it a number of times to incorporate new understanding. I must recognize that the first time I read it... I understood... nothing :-) But, in this $query up here you included "from", is it not ", BaseObject as obj......."? Please, what does mean the "," before BaseObject? Thanks! I think this is not explained in Vincent's article. Ricardo
Maybe somebody could tell if there is something quicker?
br Pascal
Thanks for your help, Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
Hello, On 4/16/08, [Ricardo Rodriguez] Your EPEC Network ICT Team < [email protected]> wrote:
Thanks, Pascal,
Pascal Voitot wrote:
Hello,
the option is the boolean "xwiki.store.hibernate.useclasstables" to put in the config...
sorry if I don't answer quickly but I'm quite busy and I can't answer in a serious manner just now... Anyway, if it can help you, I think you should read this tuto: http://www.theserverside.com/tt/articles/article.tss?l=XWiki
I think I have to read it a hundred time more :-) at least...
Even if I know a bit the class design, I'm not an expert yet :) But $xwiki.search seems not to return Object[] but Collection[] only with properties Name, ClassName and Number... Don't know why exactly but I will look at it...
So something like this seems to work for me... you retrieve the doc and then the object and then you get our Object :)
#set($query="from BaseObject obj where obj.className ='Contacts.ContactClass'") #set($results=$xwiki.search($query, 10, 0)) #foreach ($item in $results) #set($myObject = $xwiki.getDocument($item.Name).getObject($item.ClassName, $item.Number)) $myObject.get("firstname") | $myObject.get("surname") | $myObject.get("phone1") #end surname
I will follow this idea to see if I am able to understand how the mechanism does work! Vincent explanation is The Server Side must be enough. The point is to read it a number of times to incorporate new understanding. I must recognize that the first time I read it... I understood... nothing :-)
But, in this $query up here you included "from", is it not ", BaseObject as obj......."?
Please, what does mean the "," before BaseObject? Thanks! I think this is not explained in Vincent's article.
this is because in the Todo tutorial, it uses $xwiki.searchDocument which already brings one part of the HQL request... so what you write is the end of the request that's why you put "," at the beginning:) but in my sample, this is pure HQL so no problem of this kind! regards Pascal Ricardo
Maybe somebody could tell if there is something quicker?
br Pascal
Thanks for your help,
Ricardo
-- Ricardo Rodríguez Your EPEC Network ICT Team
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Thanks! Pascal Voitot wrote:
this is because in the Todo tutorial, it uses $xwiki.searchDocument which already brings one part of the HQL request... so what you write is the end of the request that's why you put "," at the beginning:)
but in my sample, this is pure HQL so no problem of this kind!
Great. It is clearer for me now. Sorry if I am quite slow understanding things, but I would like to get this issue "absolutely" clear :-) 1. By using $xwiki.searchDocument, the first part of the HQL sentence comes given by the method itself. 2. By using $xwiki.search, it will accept any HQL or XPath sentences as parameter. I found this clearly documented in... http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%2D1.3... Please, are this summary correct? Thanks! Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
Hello, On 4/16/08, [Ricardo Rodriguez] Your EPEC Network ICT Team < [email protected]> wrote:
Thanks!
Pascal Voitot wrote:
this is because in the Todo tutorial, it uses $xwiki.searchDocument
which
already brings one part of the HQL request... so what you write is the end of the request that's why you put "," at the beginning:)
but in my sample, this is pure HQL so no problem of this kind!
Great. It is clearer for me now. Sorry if I am quite slow understanding things, but I would like to get this issue "absolutely" clear :-)
1. By using $xwiki.searchDocument, the first part of the HQL sentence comes given by the method itself.
2. By using $xwiki.search, it will accept any HQL or XPath sentences as parameter.
I found this clearly documented in...
http://platform.xwiki.org/xwiki/bin/download/DevGuide/API/xwiki%2Dcore%2D1.3...
Please, are this summary correct? Thanks!
I think your summary is ok... In fact, I look directly in the code to give you information so if I'm wrong, it means I haven't understand what I read... which happens quite often ;););) Ricardo
-- Ricardo Rodríguez Your EPEC Network ICT Team
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Pascal Voitot wrote:
I think your summary is ok... In fact, I look directly in the code to give you information so if I'm wrong, it means I haven't understand what I read... which happens quite often ;););)
Thanks! I understand that this is an easy issue for programmers, but "typical" users like me usually need more help. Let's see if this could be useful... http://www.xwiki.org/xwiki/bin/preview/FAQ/HowdoIretrievepropertiesfroma Cheers, Ricardo -- Ricardo Rodríguez Your EPEC Network ICT Team
participants (3)
-
[Ricardo Rodriguez] Your EPEC Network ICT Team -
Kamna Jain -
Pascal Voitot