TIP MultiSaveContrib is not installed on Foswiki.org.


Json-RPC interface to save multiple changes in one transaction

MultiSaveContrib can be used to build wiki applications that change one or more properties in multiple topics in one transaction. So users won't have to edit each single topic turn by turn. All changes are submitted to a multi-save backend which then applies them automatically. By now, only DataForm properties can be changed. A further version of this extension will allow to change other properties as well.

This extension is heavily inspired by Foswiki:Extensions/MultiTopicSavePlugin but strips down some of its features while adding new ones thus rendering its interface incompatible to MultiTopicSavePlugin. The basic idea how to transmit a multi-save change still remains similarly.

Rendering of input forms is best delegated to Foswiki:Extensions/FlexFormPlugin which will use the Foswiki's core features to render DataForm edit widgets.


A multi-save form is created using a formatted search like this:

<form class="jqMultiSave" name="MyMultiSave">
  header="<table class='foswikiTable'>
  format="<tr><td> [[$web.$topic]] </td><td> 
      fields=\"Field1, Field2, Field3\"
      separator=\" </td><td> \"
%BUTTON{"Save" icon="disk" type="submit"}%

There are a couple of things to note:

There's a %JQREQUIRE{"multisave"}% that will load the javascript required to handle all forms having a css class "jqMultiSave" This will attach a jquery.multisave instance to this form.

The multi-save form will be posted to the appropriate jsonrpc endpoint of this extension asynchronously.

Results by the jsonrpc endpoint are processed by the jquery.multisave javascript code and displayed in a message box following the form.

The multi-save action will also transmit the form's name which helps to identify it from other multi-save wiki applications in subsequent beforeSaveHandler and afterSaveHandler (see below).

The formatted search in the example looks up topics that have a specific TestForm attached to it. In this example TestForm comprises of at least three formfield Field1, Field2, Field3.

The formatted search makes use of FlexFormPlugin's %RENDERFOREDIT macro that will generate the edit interface based on the DataForm definition of TestForm.

The form elements used to edit each formfield requires it's name attribute to be altered in a specific way so that MultiSaveContrib knows where to save this formfield. It must be of the form


For instance, the Field1_name parameter in the example above will override the normal name attribute used by %RENDERFOREDIT while creating an edit widget for that element. So changing Field1 in a topic FooWeb.BarTopic will performed by an form element such as:

<input type="text" size="75" name="multisave{FooWeb.BarTopic}{Field1}" value="..." />

All form elements that changed their values will be flagged so using css automatically. Only these will be transferred to the multi-save backend.

Adding beforeSaveHander and afterSaveHandler

Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.

Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button. Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will not show up in the search results.

You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install

If you have any problems, or if the extension isn't available in configure, then you can still install manually from the command-line. See https://foswiki.org/Support/ManuallyInstallingExtensions for more help.



Change History

05 May 2022: fix use if jsonrpc params; add support for saving preference values in addition to formfield values
25 Sep 2017: fixed use of param() api
20 Sep 2014: fixed saving of deselected checkboxes and radioboxes
04 Sep 2013: fixed manifest
30 May 2013: initial release
Topic revision: r6 - 05 May 2022, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy