@P T Withington : I looked at your your solution for creating delegates.
When i need to use the delegates, i m going to use the way that you
mentioned. While looking at the developer documentation of openlaszlo, I
hadnT understand the meaning of delegates and the usage of it. it seemed to
me a bit confused :) Now, i think know more about delegates than before,
thanks
@jamesr : also thank you for the information. I worked out the problem. I
used an attrbiute in the connection.lzx
<attribute name="connectionOK" value="false" type="boolean"/>
and in the case of "NetConnection.Connect.Success", i set it to true.
Then while creating an object of sharedObject, i used like that :
<sharedObjectChat id="soChat">
<handler name="onconnectionOK" reference="conn">
Debug.info("connectionOK attribute operation, value
:%w",conn.connectionOK);
if (conn.connectionOK==true) {
//this.setAttribute("createSharedObject",true);
this.connect("chat", conn._conn, true);
this.so.client=this;
}
</handler>
</sharedObjectChat>
So itS ok now. İt is impossible to learn something wihout making mistakes :)
Best regards.
2009/12/18 P T Withington <[email protected]>
> I have a proposed "solution" for the LZX programmer having to create
> delegates in script in:
>
> http://jira.openlaszlo.org/jira/browse/LPP-7816
>
> Basically, I want you to be able to declare a handler without attaching it
> to an event at declaration time (and you would later use script to register
> the handler on the event it is to handle). The main purpose for this change
> is that <handler /> will automatically be managed, whereas delegates must be
> manually managed (and destroyed) or they can lead to memory leaks.
>
> On 2009-12-18, at 16:03, jamesr wrote:
>
> > for the record, the two use cases for making a delegate are
> >
> > 1) you want to compute what object to latch onto programmatically and
> > 2) you want to latch onto something that is not yet created at the
> handler init phase.
> >
> > don't see any other use, although the two above are obviously important
> >
> > cem sonmez wrote:
> >> you are exactly right. I want to make some operations when the
> netconnection successful event is fired. Actually i m trying to get the
> shared object on the server side, so at first i need a netconnection
> instance to do that. ThatS why i thought that i should try delegates. I
> havenT used delegates before, but i thought that this is the just one
> solution to handle the operations depend on the related event.
> >>
> >> The method you said, using an attribute in the connection class seems
> the better way. Till now, i havenT needed the delegates. I hope using
> connection status attribute in the connection class will fix the problem.
> >>
> >> I m going to post back the results here of course.
> >> Thanks for the reply J
> >>
> >> 2009/12/18 jamesr <[email protected] <mailto:[email protected]
> >>
> >>
> >> I can tackle it. let's see; i'd write the following, after an
> >> introduction (all code is untested and represents a pattern, adapt
> >> it as you will)
> >>
> >> Your problem: You want to do is send a "connection successful"
> >> event that you can catch, signaling that a method is to be called
> >> to continue using the connection. You seem to be trying to do it
> >> by setting up the delegate manually, when i think, looking at your
> >> code, that you have hooks to fire events on laszlo nodes that can
> >> communicate this state change.
> >>
> >> Solution: An event is anytime you use x.setAttribute() by the way
> >> - that's what it does, makes sure that handlers are fired. That
> >> said, if you declare an attribute of any laszlo node and in your
> >> code, when you have success on your net connection, you say
> >> "somenode.setAttribute('success, true);" then in another node you
> >> can say, <handler name="onfoo" reference="somenode">...</handler>
> >> and in that code you can then do what ever other steps are
> >> required to use the connection.
> >>
> >> Further thought if i'm wrong: can you say why it is you decided to
> >> use manual delegates? it might make things clearer for me, i've
> >> not used the net connection code you have there but make guesses.
> >>
> >> .j.
> >> cem sonmez wrote:
> >>
> >> doesnT anyone have any idea. I got stuck here. Waiting for
> >> someones advices.
> >> Thanks
> >>
> >> 2009/12/18 cem sonmez <[email protected]
> >> <mailto:[email protected]> <mailto:[email protected]
> >> <mailto:[email protected]>>>
> >>
> >>
> >> hi
> >> when i try do use the delegate such like :
> >>
> >> if( typeof this.del == "undefined" ) {
> >> this.del = new LzDelegate(this, "connect('chat',
> conn,
> >> true)" );
> >> } this.del.register(conn,
> >> "netStatusHandler('NetConnection.Connect.Success')" );
> >> }
> >>
> >> I m getting the error on the debug like :
> >>
> >> *soChat.connect('chat', conn, true) => (void 0) (must be a
> >> function)*
> >>
> >> Actually i want to do this : call the *connect* method on the
> >> class when the netStatusHandler method of the *conn* object
> has
> >> been completed. I m not sure that am i using the delegate
> >> correctly (as i m getting the error, of course not :)).
> >>
> >> I have attached the relevant files.
> >> Can anyone help me what i m missing to do.
> >>
> >> Kind regards.
> >>
> >> -- Cem SONMEZ
> >>
> >>
> >>
> >>
> >> -- Cem SONMEZ
> >>
> >>
> >>
> >>
> >> --
> >> Cem SONMEZ
>
>
--
Cem SONMEZ