I want to reuse some Domino pre 8.5 forms in my web apps as popup forms from an Xpage to fill out some data and then return the values back into an XPage field.How do I get a handle to the Xpage field from the form popup in order to write back a value?
I have tried on the form to write back to the xpage:
window.opener.document.getElementById(‘myNames’).value= somevalue;
and
window.opener.document.forms[0].myNames.value=somevalue;
with no success.
both return a ‘is null or not an object’
Subject: Getting ID
The problem is, if you look at the HTML produced, the ID will not be myField. It’ll be at least view1:_id1:myField. There’s a very good reason for that: if it used the ID you put in, you couldn’t do a repeat control, you couldn’t use a custom control twice on the same XPage.
You need to get a handle on how to work out the bit before that. This shows how to get the ID of an element http://www-10.lotus.com/ldd/ddwiki.nsf/dx/element_ids_in_client_side_javascript_on_xpages.htm
What I’ve done in the past is created a computed text field called elementPath and used this formula for its value: @LeftBack(getClientId(“elementPath”), “elementPath”)
With a bit of lateral thinking, you can place that in a normal HTML span with a specific ID, get that span, so calculate what the actual ID of your field will be.
Subject: Solution to post data on Form popup back to Xpage
Thanks Paul. I was able to identify the field ID on the Xpage
myTargetedField=‘#{javascript:getClientId(“myNames”)}’;
send that result in the url that opens the Form.
Then parse out the url on the Form in to myVar and use that to post data back to the Xpage using:
window.opener.document.getElementById(fieldPopulate).value=myVar
Subject: Quicker than getClientId
For future reference, you can use myTargetedField=“#{id:myNames}”
If you use it a lot, this could eed things up for you.