Version 9, changed by ScottMcmullan. 09/07/2006. Show version history
Creates a new page or updates an existing page. See also saveForm.
| Javascript | jot.lib.savePage(path, propertyValueMap); |
| REST | http://yourjotsite.jotspot.com/_/cmd/savePage?&path=path&pnamenn=pname&pvaluenn=pvalue |
path | The path to the page that you want to create or update. Can be null if the form includes both defaultParent and pageName controls. |
propertyValueMap | A map of the properties you want to save. The map syntax looks like: { property1-name : property1-value [, property2-name : property2-value, ...] } |
pname1, pvalue1, pname2, pvalue2, etc. | In environments where it is impossible to pass a map of arguments (e.g. via REST), you can use alternate syntax: pname1=some/property, pvalue1=Whatever, pname2=some/otherProperty, pvalue2=Whatever. |
ptype1, ptype2, etc. | Explicitly specify the types for each parameter. E.g. string, stringList, element, integer, etc. |
editStyle | Optional. Can be xml or markup. |
This call uses the alternate pname1 : pvalue1, pname2 : pvalue2, etc. map syntax.
<jot:script>
jot.lib.savePage({
path: "/PathTo/SomePage",
pname1: "MyForm/name",
pvalue1: "Elephant",
pname2: "MyForm/size",
pvalue2: "big",
pname3: "MyForm/color",
pvalue3: "grey"
});
</jot:script>
Update a page called ContactPage7 by appending a string to main/text, and setting a the firstName property of the page's ContactForm form.
<jot:script>
var contactPage = jot.pages["ContactPage7"];
var existingText = contactPage.main.text;
var newContact = "Jerry";
jot.lib.savePage(contactPage.path, {'main/text': 'This will be appended to the existing text on the page',
'ContactForm/firstName': newContact});
</jot:script>
Save a string to the main/text property of a page called MyTestPage.
<jot:script>
jot.lib.savePage('/WikiHome/MyTestPage', {'main/text': 'This will be the only text on the page'});
</jot:script>
In addition to string literals, you can pass numbers and XML (XHTML) literals using E4X.
<jot:script>
jot.lib.savePage('/SomePage', {
'main/text': <html>this is fancypants literal HTML with E4X</html>,
'main/other': new XML('<p>you can also create XML from a string</p>'),
'some/otherProp': 123,
'and/anotherProp': 'this is a plain old string'
});
</jot:script>
This example creates the page called 'SomePage', writes 'Hello World' in the page's main/text field and sets the page's 'myProperty' value.
<jot:script>
jot.lib.savePage('/SomePage', { 'main/text': 'Hello World',
'MyForm/myProperty': 'new value for myProperty' });
</jot:script>
Dana Weekes said via email, 08/28/2006:
Hi Scott:
I have fixed the problem I was having with SavePage but now encountering difficulties getting SaveForm to work.
I have tried the example you have online for copying it into the browser window (which would be the same format from my program). It creates the pages and says it successfully created the page but the page is always empty. Below is the string I am inputting into the browser window and the resulting output results.
https://jcsgwiki.jot.com/_/cmd/saveForm?form=StructureForm&path=/WikiHome/testpage&pname1=StructureForm/targetId&pvalue1=123
<?xml version="1.0" encoding="UTF-8" ?>
<response xmlns="http://www.foopee.com/ns/s3" status="ok">testform1</response>