Using properties in the Wrapper

2 views
Skip to first unread message

Pedro Fraca

unread,
Jan 17, 2008, 11:35:40 AM1/17/08
to JNEXT discussion group
Hi, I'm trying to use properties in the JavaScript layer instead
functions. But I need that property has the value returned by a
function. I'm trying differents ways, buts doesn't work anyway. Anyone
has an idea to do it?.

I try some similar to this:

function Contacts()
{
var self = this;

self.init = function()
{
alert('crea contacto');
if ( !g_JNEXTDispatcher.require( "Contacts" ) )
{
return false;
}
self.m_strObjId =
g_JNEXTDispatcher.createObject( "Contacts" );
if ( self.m_strObjId == "" )
{
alert( "error initializing Contacts" );
return false;
}

g_JNEXTDispatcher.registerEvents( self );
}
self.Name = function()
{
var strVal = g_JNEXTDispatcher.invoke( self.m_strObjId, "Name",
"" );
return (strVal);
}
self.getId = function()
{
return self.m_strObjId;
}
self.NameProperty = self.Name();
self.m_strObjId = "";
self.init();
}

I need to show the value returned in the Name funcction in the
property "NameProperty".

Regards.

Pedro

Amnon David

unread,
Jan 17, 2008, 1:27:14 PM1/17/08
to jn...@googlegroups.com
Hi Pedro,

>From your code it seems that you are calling:

self.NameProperty = self.Name();

too early (before the "Contacts" object is created).

Try changing the order of the calls as follows:

self.m_strObjId = "";
self.init();
self.NameProperty = self.Name();

Hope this helps,
Amnon

Pedro Fraca

unread,
Jan 18, 2008, 3:26:05 AM1/18/08
to JNEXT discussion group
Hi Amnon, the solution works propertly.

Thanks Again.

Regards.

Pedro.
Reply all
Reply to author
Forward
0 new messages