Wiki source code of Computed Pseudofield

Version 1.2 by Robert on 2018/03/11

Show last authors
1 Computed Pseudofields, also known als //calculated fields// or //computed fields//, are fields that rather compute than store they value. Unlike the other field types, like text fields, they contain a "formula" or script that describes the computation of the value instead of a user entered value.
2
3
4 =Use cases=
5 Computed fields are mainly used to:
6
7 * Extract values from another field's value, e.g. the middle inital from a middle name field
8 * Combine multiple fields, e.g. the display name as a combination of first name, middle inital and last name
9 * Calculations based on a value from one or more other fields, e.g. the grand total based on the VAT and the net price fields.
10
11
12 = Features and Limitations=
13 Let's have a look at their features and limitations:
14
15 ; defined at design-time
16 : Calculated fields are entirely defined by the author of a class, that means standard users without programming rights cannot change anything about them. They don't have a value property and the script is defined by the author of the class.
17 ; calculated at run-time
18 : Everytime a page containing a computed field is requested the value of the computed field is calculated. That means, that the computed field always shows current value, even if it is used to display something highly volatile like the current date and time. But that also means, that you should not overdo it with the number of computed fields and their complexity, else you wiki may decrease in performance
19 ; read-only
20 : The standard display for view and edit mode of an calculated field is read-only. So users of your wiki cannot enter any data into the calculated field but only read the value of the calculated field. The value of the computed field will change if the user changes a value of a field that the computed field is based upon.
21 ; not queryable
22 : Unlike other fields the value of the computed field is not stored in the database and therefore cannot be part of xwql or hql queries.
23
24
25 In xwiki the "formula" describing how to compute the value is defined in the script property of the field definition and can be further adjusted using the custom display property.

Get Connected