public class SampleNotifier extends DSENotifier {
public DSEEventObject printerEvent;
}
public SampleNotifier () {
super();
}
public SampleNotifier(String aName) {
super(aName);
}
public void printerError(String aPrt, String aDocName, String message) {
Hashtable eventAttributes = new Hashtable();
eventAttributes.put ("printerAddress", aPrt);
eventAttributes.put ("document", aDocName);
printerEvent = new DSEEventObject("printerEvent",this,eventAttributes);
signalEvent(printerEvent);
}
You can integrate the standard Java™ events within the toolkit's client event management if the JavaBean implements the Notifier interface and it is a handler (listener) of all standard Java events that it fires.
public class PrinterEventsHandler extends DSEHandler { } public Handler dispatchEvent(DSEEventObject anEvent) { // The dispatch method displays a string in the system standard output // containing the event information System.out.println("The event"+ anEvent.getName()+ "has been signaled. Printer:"+ anEvent.getParameters().get("printerAddress")+" Document:" +anEvent.getParamenters().get("document")); // The handler enables further event propagation by returning this // return this; }
In this case, the dispatchEvent does nothing but output a message to the system standard output. Note that if you do not want to propagate this event to the next registered handler, the dispatchEvent must return null.
import com.ibm.btt.base.*; import com.ibm.btt.clientserver.*; public class myClientOperation extends DSEClientOperation { public PrinterEventsHandler eventsHandler; } public void execute() throws Exception() { // Start to handle an local event eventsHandler= new PrinterEventsHandler; eventsHandler.handleEvent("printerEvent", "SampleNotifier", getContext()); // The application can continue its operation flow. The handler // processes the event as soon as it is fired. }
When the SampleNotifier instance fires an event, it calls the dispatchEvent method of the PrinterEventsHandler. In the handler displays a message in the system standard output.