Last modified by Michael Hamann on 2022/01/25

Show last authors
1 You can enable in-place editing for an existing XWiki application, if you're using the [[Vertical Form>>Documentation.DevGuide.FrontendResources.VerticalForms.WebHome]] layout, by editing the application sheet (the page used to display the application entries) and operating 2 changes:
2
3 1. Load the JavaScript code required for in-place editing and define some variables:(((
4 {{code language="none"}}
5 #set ($discard = $xwiki.jsfx.use('uicomponents/edit/editableProperty.js', {
6 'forceSkinAction': true,
7 'language': $xcontext.locale
8 }))
9 #set ($object = $doc.getObject('Path.To.YourClass'))
10 #set ($editing = $xcontext.action == 'edit')
11 {{/code}}
12 )))
13 1. Add some meta data to the definition term (##dt##) elements that wrap the field names:(((
14 {{code language="none"}}
15 <dt #if (!$editing && $hasEdit)
16 class="editableProperty"
17 data-property="$escapetool.xml($services.model.serialize($object.getProperty('yourProperty').reference))"
18 data-property-type="object"#end>
19 {{/code}}
20 )))
21
22 The result should look like this:
23
24 {{image reference="editObjectPropertyInPlace.png"/}}
25
26 Example usage:
27
28 * [[FAQ Application Tutorial>>Documentation.DevGuide.Tutorials.FAQTutorial.FAQTutorialManual||anchor="HCreatethePageDesignSheet"]]
29 * [[XClass Application>>extensions:Extension.XClass Application||anchor="HDefaultObjectSheet"]]
30
31 == Creating New Objects ==
32
33 {{version since="14.0RC1"}}
34 In-place editing also supports creating new objects. For this, the attribute ##data-object-policy="updateOrCreate"## needs to be added to the ##<dt>##-element. A use case for this is adding an additional property to the [[information tab>>Documentation.DevGuide.ExtensionPoint.Information Document Docextra.WebHome]] below the content that is stored in an object of the document which doesn't exist on all documents.
35
36 For displaying the initial property value in the ##<dd>##-element you can create the object and its property using the ###createObjectAndPropertyIfMissing##-macro. It supports an object reference in the form ##Some.Class[number].someProperty## where the ##[number]##-part is optional and denotes the number of the object to edit. Note that this modifies the (copy) of the document in the current context which might not be desirable. As an alternative you can check if the object exists and if not just manually display the default value of the property. An example for this can be seen in the [[activation UI>>https://github.com/xwiki-contrib/application-numbered-content/blob/1b8b67135f4abf24a28c45a6a83db6de996b1941/application-numbered-content-headings-ui/src/main/resources/NumberedHeadings/Code/ActivationUI.xml#L367]] of the [[Numbered Headings Application>>extensions:Extension.Numbered Content.Numbered Headings Application.WebHome]].
37 {{/version}}

Get Connected