Following up:
The solution I posted earlier only works in the IDE ... not when deployed to a server. Once deployed, the service call comes from the server, not the client. Therefore, the IP address that is resolved is the IP address of the server. Not very useful (smacks forehead)!
There is another way to skin this cat. With the same scripted HTML setup described in my earlier post, use the following external type in your Rich UI client.
com.mycompany.custom.widgets.BrowserFunctions.egl
externalType BrowserFunctions extends Widget type JavaScriptObject {
relativePath = "com/mycompany/custom/widgets",
javaScriptName = "BrowserFunctions" }
function getIP() returns(string);
end
com/mycompany/custom/widgets/BrowserFunctions.js
egl.defineClass(
'com.mycompany.custom.widgets', 'BrowserFunctions',
{
"constructor" : function()
{
},
"getIP" : function () {
xhttp=new XMLHttpRequest();
xhttp.open("GET","http://www.mycompany.com/getIP.shtml",false);
xhttp.send("");
x=xhttp.responseText;
return x;
}
});
Then, in your Rich UI code:
import com.ibm.egl.rui.widgets.*;
import com.mycompany.custom.widgets.BrowserFunctions;
handler Test type RUIhandler {initialUI = ui }
ui Box{ columns = 1, width = "400", height= "400", children = b1, l1 };
b1 Button{ text="Who Am I?", onClick ::= onClick_b1 };
l1 TextLabel { text="-------------------------------" };
function onClick_b1(e Event in)
browserFunctions BrowserFunctions {};
l1.text = browserFunctions.getIP();
end
end
With this approach the invocation of the scripted HTML page comes from the client side and the address returned is that of the client.
--Dan
dan_darnell