Save a document property value with a javascript value

Hi,

I want to save a property value getted by javascript (a facebook access token given by the facebook login process) to the current document viewed. The document is in VIEW mode for this login action so i can't use the regular process for saving the current document.

Technically, i'm on a Template widget of the property in VIEW mode and i have a javascript variable with my value. How can i put the javascript value into the property value of the document and how i save it after ? (ajax ?)

Thanks

0 votes

1 answers

2373 views

ANSWER



Hi,

The best option is to use the Automation JS client to directly call an update operation on the server side. This is what is done in the new Select2 based widgets.

In your case, you should already have access to JS Automation Client inside the global context.

 var options = {automationParams : {
       params : {},
       context : {},
       input : { 'doc:' + window.ctx.currentDocument}       
   }}
var op = jQuery().automation("Document.SetProperty", options);
op.addParameter("xpath", propertyXPath);
op.addParameter("value", propertyValue);
op.execute();

This will update the Document inside the repository. If you want a better integration with JSF/Seam, you may want to define a Chain that will do the update + trigger a refresh in Seam.

Tiry

0 votes