Welcome, guest ( Login )

» Home (JDC Blog)
» Forums

Page Tags

savePage ssjs REST

Search Tags:
WikiHome » JotDoc » Reference » SavePageRef

SavePageRef

Version 9, changed by ScottMcmullan. 09/07/2006.   Show version history

JotSpot Developer Documentation

See the auto-doc viewer for additional documentation on this API

savePage

Creates a new page or updates an existing page. See also saveForm.

Syntax

Javascriptjot.lib.savePage(path, propertyValueMap);
RESThttp://yourjotsite.jotspot.com/_/cmd/savePage?&path=path&pnamenn=pname&pvaluenn=pvalue

Arguments

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.


Examples

Browse examples by embedding syntax

Server-side Javascript | JotScript | REST


  1. Using savePage to set property values by ScottMcmullan
  2. Updating a page by ScottMcmullan
  3. Setting a page's main/text property by ScottMcmullan
  4. Setting properties using E4X by ScottMcmullan
  5. Creating a page and setting page properties by ScottMcmullan


Using savePage to set property values

by ScottMcmullan

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>



Updating a page

by ScottMcmullan

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>



Setting a page's main/text property

by ScottMcmullan

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>



Setting properties using E4X

by ScottMcmullan

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>



Creating a page and setting page properties

by ScottMcmullan

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>




Add an Example

Log in to post an example

Comments (1)

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>

 

 

 

 

 

 

 

 

Attachments (0)

  File By Size Attached Ver.