Notification

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Notification

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:34 pm

by Jade Starter >> Tue, 6 Apr 2004 11:27:44 GMT

Hi,

I want to send a notification to an object that is not known to the one thatbegin s the notification. Is it possible to send the notification to all
active forms in Jade?

If this doesn't work, how can I implement a form that keeps track of all the users actions?

Thanks for all your help!

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Notification

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:34 pm

by dcooper@jade.co.nz >> Wed, 7 Apr 2004 7:18:31 GMT

Pick an object (the target) that *is* known to both the subscriber (the process that does the beginNotification) and the process that raises the notification (causes the events).

Typically you'll want a persistent object for this. If you're wanting to write a form that keeps track of all actions for a user, then presumably you've got a class in your system (User, for example) for which there is one persistent instance for each user that can sign on. If so, then you could set up your notifications something like:

1. Have a combo box or something on your monitor form that lets you pick the persistent User object whose actions you want to monitor. When this is clicked, do something like:

// easy way to end all notifications
endNotificationForSubscriber(self); // self is the form
// subscribe to notifications for the selected userbegin Notification(userCombo.itemObject.User, UserEvent,
Response_Continuous, 0);

UserEvent is a constant Integer representing the event and should be greater than the RootSchema's User_Base_Event global constant (16).

2. Presumably you have a reference somewhere (app.myUser, for example) that references the currently signed-on user for a process (eg: it's set when a user signs on). Given this, anywhere that you want to cause an event that is to be tracked by any open monitor form, you can just code:

infoString := ...some details about the event...; app.myUser.causeEvent(UserEvent, true, infoString);

Passing "true" for the second parameter indicates that the event is to be caused immediately - I've assumed this is what you want. If you pass "false" for this parameter, then the event will be caused only at the next commitTransaction. This is useful when you want to cause events that you know will be dispatched only when the current transaction commits successfully. Use infoString to pass through details about the event if required (eg: a string to display in a listbox on your form, for example). This is limited to 49K in size. If not required, just pass null.

3. The userNotify method on your monitor form would look something like:

userNotify(eventNo: Integer; obj: Object; tag: Integer; info: Any) updating; vars
infoString : String;begin

if eventNo = UserEvent then
infoString := info.String;
...update the form and display infoString somewhere...
endif;
end;

If you have lots of different events then you may want to have a constant per event (ie: instead of UserEvent, you have UserEventA, UserEventB, UserEventC, etc) and cause specific notifications for each one. This would mean that your form would have to register for several notifications, but you could then allow the user to select the events that they're interested in. Depends on what you want.

Cheers,
Dean.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Notification

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:34 pm

by Kevin and Maureen >> Wed, 7 Apr 2004 7:49:05 GMT

Hi,

You can use the singleton system object.

For the application (on, say the form load) which is to receive all the user actions do

beginNotification(system, Actions, Response_Continuous, 0); - where Action is an Integer Global Constant with a value > 16

Then the on the userNotify method of that form you will receive all the appropriate notifications.

Now whenever you need to cause an event do

system.causeEvent(Action, true, <whatever you want>); - whatever you want can be any primtive or a persistent object

Kevin

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Notification

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:34 pm

by Jade Starter >> Wed, 7 Apr 2004 12:27:09 GMT

I got it to work now. Thanks for the ideas.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 31 guests