Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can Javascript write data dynamically to a Confluence page?

Clay Monkus August 9, 2011

I am trying to use confluence to display charts that are dynamically built using REST calls to a seperate database. I already have the Javascript runinng on a confluence page to manually do the REST request but I am not sure if it is possible to take the CSV data that I get back from the REST request and write it to the Confluence page.

What I am trying to accomplish is that a user clicks on a Confluence page, that page executes the Javascript which returns a CSV value, that value is then written onto the Confluence page wrapped in the {csv} macro which builds a table. From the user perpsective, all they would see is a table that is displaying current data from the third party database. And that table would look like all the other Tables in Confluence.

Where I am stumped is in knowing if it is even possible to write content to the Confluence page using Javascript.

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Remo Siegwart
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 28, 2011

Not sure if this helps, but the csv macro is capable of displaying csv data from urls directly:

{csv:url=http://your-url-to-the-rest-interface}

It's a simple solution to access csv data from other applications (for example: data from Wufoo forms) and it works pretty good. You can then even wrap the code in a chart macro, to display the data as a chart.

Cheers
Remo

1 vote
Alexander Johannes
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 9, 2011

As javascript is normally executed on the client side, your script will only be able to modify the rendered content of a confluence page. But if i understand correcly, you are trying to modify the wiki-text just before rendering.

I would be surprised, if there are any hooks built into confluence, to achieve something like that.

The only way i see it working, is to write your own macro-plugin, which gets executed during the rendering of the relevant page.

0 votes
Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 29, 2013

Hi Clay,

If you use javascript to input data in a page, you'll face a cross-domain problem: Your javascript can't read from one domain (as in, something.com) and write it into another page (like confluence.yourcompany.com), unless you perform a bit of magic (see the keyword: CORS).

So it would probably be easier to use Bob Swift's CLI to insert data in Confluence.

Cheers,

Adrien

0 votes
Brendan Patterson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2012

Yes is the answer I believe. You can use JavaScript to connect back to the Confluence server and pass it data to be written to a Confluence page.

Using JavaScript and AJAX you can connect back to the server and manipulate Confluence pages on the server either via the Remote API(SOAP and XML-RPC....prob not ideal) or further extend Confluence's REST access points by implementing a REST Module plugin.

Another approach would be to implement a plugin module type of "servlet filter" to intercept certain 'queries' back to the server. And do things - basically this would be an unstructured html request like using REST, but outside that framework.

So there are at least four ways to do this.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events