Save a document property value with a javascript value


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 ?)


0 votes

1 answers




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);

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.


0 votes