XPages: Data Binding with Java Script

In order to save values from an XPage in a form you use simple databinding. Setting the field on the Xpage to the value of the field on the form.

But I am using computed fields for parts of my XPage and calculate the value using a javascript. How do I bind these values to the fields on my form so that save in the docuemnt that is created when I click save on my XPage? If I use simple data binding it removes the javascript which I need to craete the value in the first place.

Do I need to simply add another line of code to my javascript in order to get the value I calculate in my computed field to transfer to the document/form on saving. If so what is it?

I have tried document.fieldvalue;

I have tried using replaceitemvalue

I might have done these in the wrong format.

I tried changing the xml so that it did the binding in the <xp: text tag and then I had my javascript in the xp:this value tag but it told me that I had already declared this value and gave me an error.

Subject: Tried with edit field

Tried using an Edit Field to make the binding and have the script also. But now have values still do not write into the document

Subject: Example code

Could you provide a sample code of what you are trying to achieve?

In some cases, I’ve found that I need to do the replaceItemValue() in a server side script that runs when I hit the save button, but before actually saving the document.

Subject: Fotr example

This code gets me a remote user value from the CGi

var cgivar='Remote User: ’ + facesContext.getExternalContext().getRequest().getRemoteUser();

return cgivar

The value displays in the XPage when I set the Edit Box to visible. Also it saves in a field in a NOte form whcih I have bound the XPage value to.

But if I make the XPage value invisible on the XPage then the value does not save on the form