DataModel
XWiki Data Model
XWiki is not just your average wiki engine; it exposes a flexible data model that can be leveraged at the presentation level. Combined with its powerful presentation level scripting capabilities, XWiki's data model can help you build simple to complex Web applications with little or no need to access the XWiki core. In other words, you can build custom applications through the XWiki web interface without having to compile, package, and deploy software components.
This area explains XWiki's data model of Classes, Properties, and Objects for those users who want to build applications primarily at the presentation level. It will help you understand how you can achieve significant functionality by programming at this level alone. For information about XWiki's underlying database schema (tables and fields), see: More on the Data Model.
XWiki Classes, Objects, and Properties
If you are familiar with object oriented programming, you understand the concept of classes, properties, and and objects. The presentation level data model that XWiki exposes is much the same.
- Classes
- An XWiki class is like a template that defines a unique type of object. It defines what properties an object can have. When you define a custom class, you are saying that your application may need to create one or many objects (instances) of that class. The class itself is like a cookie cutter and the objects are unique instances of that class. So, in this analogy, if the class is the cookie cutter, the objects are the cookies (and we are talking about real edible cookies in this analogy; not Web cookies).
- Properties
- Properties are the characteristics that an object can have. In a class definition, the properties define the data fields that each unique instance of the class can have values for.
-
XWiki currently supports the following kinds of properties (datatypes) which will be explained later in greater detail:
- Number
- String
- TextArea
- Password
- Boolean
- Static List
- Database List
- Date
- You may find the labels for the property types somewhat confusing because in the XWiki Class Editor, they also contain the word 'Class'. For example, you will see Number Class, String Class, TextArea Class, and so forth. It is best if you just ignore the word 'Class' and think of them as simple property datatypes in the traditional sense for now.
- Objects
- Objects are unique instances of a class with unique values defined for each of the properties that make up the class.
In summary:
- Classes define an object type and the properties that are possible for an object of that type to have.
- Properties define the types of data that unique objects can have. The property types (datatypes) are defined for the class, but the actual values for the properties are defined for the objects when the objects are instantiated from the class.
- Objects are unique instances of a class with unique values for all of the properties that the class definition allows the objects to have.