This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



May 14, 2012, 9:26 PM
24 Posts
topic has been resolvedResolved

Populate fields on XPage in client side Javascript

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 4
To populate fields on an XPage while in client side Javascript, do you have to reference by element or ID?
 
From what I can tell, can you use:
 
document1.replaceItemValue("this value", thisField);
 
Or do you need to get a handle on the document some other way?
 
I have a button that performs a lookup to an external source using a servlet, Dojo, and JSON.
 
I can grab the correct name and it's value no problem, just not sure how to get that back to the XPage...
 
It is probably simpler than I think, but an example would be great...
 
Thanks!
Dan
May 15, 2012, 7:32 AM
126 Posts
Re: Populate fields on XPage in client side Javascript
If I understand the question correctly, the easiest way to show document data on an XPage is to bind a control to a field. such as:
 
<xp:label value="#{doc1.Body}"></xp:label>   This is using the JSF expression language. If the field has data it will be displayed here and vice versa if it has no data (and this control was a text field) typing content in here and executing a save would save that data to the domino doc field.
 
There is no way to interact with a domino document using only client side, domino docs are held on the server and in order to access them you will be required to use serverside script. If you need to use client side there are ways of matching the 2. The following URL has some great examples: 
 
May 15, 2012, 7:52 PM
24 Posts
Re: Populate fields on XPage in client side Javascript
I reviewed both sites -- thanks very much!
 
However, I am not sure I can do this using the RPC or calling server side in client side...
 
Here is what I am doing:
1. User clicks button to call out to a servlet, returning JSON that I grab the name/value pairs from
2. I now have a value I need to populate a field in the document on the client side -- that is, the document has just been created (it is "new") and I need to put a value into a field
 
From my old Javascript days, I thought you could use:
document.forms[0].thisField.value = "Hello";
 
To populate a field on a document.  Can this be done in XPages?
 
Something like:
var doc = document.forms[0];
doc.thisField.value = "Hello";
 
From what I can tell, it looks like the field names (<input>) are dynamically changed when rendered on the web.
 
Could I use something like:
document.getElementById("thisField").value = "Hello";
 
Any help would be great...
 
Thanks!
Dan
May 15, 2012, 9:32 PM
24 Posts
My solution...
 To populate the fields client side, here is what I did...
 
                               var doc = document.forms[0];
                               for(var x = 0; x < doc.elements.length; x++){
                                        if(document.forms[0].elements[x].name=="#{id:fieldName1}" ){
                                            document.forms[0].elements[x].value = "Hello";
                                        }
                                }
 
Seems to work OK...

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal