Events in classes.
Hi all
Can any one explain me the functionality about events and event handlers in ABAP OO??
Thanks and Regards,
Arun Joseph
Hi there
Whilst the SENDER doesn't know about the RECEIVER the reverse is not true. Some people might (wrongly) infer from the comment about the sender that the receiver doesn't know either. I'm only adding the comment below hopefully to clear this up for some people who perhaps a new to OO programming and OO ABAP in particular.
By using the parameter SENDER the receiver can know what object triggered the event. This is of course useful where you have say multiple grid displays on the screen and an action needs to be performed depending on what object triggered it.
class lcl_event_handler definition.
* CLASS cl_event_receiver
* DEFINITION
public section.
methods:
*--To add new functional buttons to the ALV toolbar
handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive
sender,
*--To implement user commands
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm
sender,
class lcl_event_handler implementation.
*--Handle Toolbar
method handle_toolbar.
* PERFORM handle_toolbar USING e_object e_interactive .
endmethod .
*--Handle Hotspot Click
method handle_hotspot_click .
* PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
create object go_handler.
set handler go_handler->handle_user_command
for go_grid1.
set handler go_handler->handle_user_command
for go_grid2.
form handle_toolbar
case g_sender
when go_grid1
etc
sorry if this info is a case of "stating the obvious" but reading the forums there's quite a bit of confustion surronding event generation and handling in OO ABAP.
Cheers
jimbo
Similar Messages
-
Events in classes LabVIEW 8.6
i have class with some member (counter of something)
and i want to generate a user event when this member has specific values.
currently i manage to generate the event only if i register the event of the class
in the Top Vi that use this class
can i register the event inside the class itself, let say inside the initilize vi that i ave for the this class ?
thanks
Solved!
Go to Solution.The question is a little confusing. You can register for the event anywhere you like, but somewhere you pretty much need to have an Event Structure in a running VI waiting for that event to occur.
What should be aware of these events? Class members
P.S. On second reading, it seems you might just be asking if you can register the event in a class VI, instead of having to register it in the top-level VI. If that's the case, then yes you can. Just have the Register for Events function inside the Initialize VI of your class and have it output the Event Registration Refnum corresponding to your event.
Message Edited by Jarrod S. on 11-02-2008 08:48 PM
Jarrod S.
National Instruments -
Creating a singleton Event Listener class
A typical singleton OO design pattern involved a protected (or private)
no-arg
constructor and a public instance() method that manages a private static
variable
referencing the single instance, internally invoking the no-arg constructor.
A class designated in web.xml as a <listener> must have a public no-arg
constructor.
(from http://e-docs.bea.com/wls/docs61/webapp/app_events.html#178593)
Anyone thoughts on how to accomplish both goals?
What I want to do: I'd like to set up a singleton to listen for session
events.
Other code will query this one-and-only-one session event listener for
various
information. Some of this info I can currently get from the runtime via
MBeans but
some I can't, hence my investigation into session event listeners.
TIA, matt.Hi Matt,
This sounds like a case where you will need to have two classes -- your
singleton class, and then your session event listener class, which would use
the singleton class.
Dennis Munsie
Developer Relations Engineer
BEA Support
"Matt Hembree" <[email protected]> wrote in message
news:[email protected]..
A typical singleton OO design pattern involved a protected (or private)
no-arg
constructor and a public instance() method that manages a private static
variable
referencing the single instance, internally invoking the no-argconstructor.
>
A class designated in web.xml as a <listener> must have a public no-arg
constructor.
(from http://e-docs.bea.com/wls/docs61/webapp/app_events.html#178593)
Anyone thoughts on how to accomplish both goals? -
JTabbedPane single event handling class.
I have a list of proxyNames which are stored in a Vector.
These proxy names are then displayed as Tabs accordingly.
For every tab there is a specific action to be performed.
I want to write a single event handling class for handling all events.
What I have is this:
while(eNum.hasMoreElements()){
Object proxyName = eNum.nextElement();
tabbedPane.addTab(proxyName.toString(), null, null, "Proxy");
tabbedPane.addChangeListener(itemHandler);
panel4.add(tabbedPane2);
class ItemHandler implements ChangeListener{
public void stateChanged(ChangeEvent e){
for(int i=0; i < v.size(); i++){
// Perform action on choosing the concerned tab...
How do I have a single event listener?Yikes! Is that a minimal program? When I am trying to do something new, or facing a problem that causes me to get stuck for more than an hour, I create a short program to solve just that problem. In time, you create a directory of test programs that's useful, and with practice, solving a problem in isolation is a faster (and generally better) way to go about things that doing it all in a larger application.
Any way, here is your code, with a change listener added in method makeSubpanel. If you don't want the listener called the very first time, add it at the end of this method. I also fixed some bugs in createProxyList.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class TrialTabbed extends JPanel {
// Will hold all file names read from the /config directory.
private Vector v,v1;
JTabbedPane tabbedPane,tabbedPane2;
Object proxyName;
public TrialTabbed(){
tabbedPane = new JTabbedPane();
// Instantiate the Vector.
v1 = new Vector();
Component panel1 = makeTextPanel("Blah");
tabbedPane.addTab("Debug Mode", null, panel1, "Debug");
Component panel2 = makeSubPanel();
tabbedPane.addTab("Normal Mode", null, panel2, "Normal");
// Add the tabbed pane to this panel.
setLayout(new GridLayout(1, 1));
add(tabbedPane);
protected Component makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
private Component makeSubPanel(){
JPanel panel4 = new JPanel(false);
panel4.setLayout(new GridLayout(1, 1));
tabbedPane2 = new JTabbedPane();
//new code - a change listener for pane2
tabbedPane2.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
int tab = tabbedPane2.getSelectedIndex();
if (tab == -1)
System.out.println("no tab selected");
else {
String filename = tabbedPane2.getTitleAt(tab);
File file = new File("..", filename); //brittle!
if (file.isDirectory()) {
String[] contents = file.list();
int size = contents == null ? 0 : contents.length;
System.out.println(filename + " contains " + size + " files");
} else
System.out.println(filename + " has length " + file.length());
//end of new code
ItemHandler itemHandler = new ItemHandler();
v = createProxyList();
// Enumerate thru the Vector and put them as tab names.
Enumeration eNum = v.elements();
while(eNum.hasMoreElements()){
proxyName = eNum.nextElement();
tabbedPane2.addTab(proxyName.toString(), null, null, "Proxy");
panel4.add(tabbedPane2);
return panel4;
// Display the file names in this directory as tab Names.
//new code: changed dirName to "..", fixed some obvious bugd
private Vector createProxyList(){
String dirName = "..";
File file = new File(dirName);
if(file.isDirectory()){
String[] s = file.list();
for(int i=0; i< s.length; i++){
v1.addElement(s);
} // End for.
} // End of if.
return v1;
} // End createProxyList().
class ItemHandler implements ChangeListener{
public void stateChanged(ChangeEvent e){
System.out.println(v.size());
System.out.println("IN CHANGE LISETENER" + proxyName.toString());
} // End actionPerformed.
} // End Inner class ItemHandler.
public static void main(String[] args) {
JFrame frame = new JFrame("TabbedPaneDemo");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
frame.getContentPane().add(new TrialTabbed(),BorderLayout.CENTER);
frame.setSize(500, 425);
frame.setVisible(true); -
Broadcast events between classes (objects)
Hello,
I'm can't figure out how to broadcast an event to another
class.
In actionscript 2 I created 2 classes. The first class called
the second class to load a file from an url. When the file was
loaded I used dispatchEvent({type: "fileLoaded", target: this,
filename: sFilename})
In the first I simply wrote addEventListener("fileLoaded",
handleFile)
But with AS3 this no longer works.
Can anyone tell me how to accomplish this? Because I can't
find a clear example and I don't know how to do this.In the defintion of your custom event I miss the isEnabled
part (don't know if that has anything to do with the issue though).
Below a custom event that works for me
package Components {
import flash.events.Event;
public class ZoomEvent extends Event
public var isEnabled:Boolean;
public static const ZOOM:String = 'zoom';
public var vertical:Boolean = true;
public var minvalue:Number = 0;
public var maxvalue:Number = 0;
public var zoomfactor:Number = 0;
public function ZoomEvent(type:String,
isEnabled:Boolean=false) {
super(type);
this.isEnabled = isEnabled;
public override function clone():Event {
return new ZoomEvent(type, isEnabled);
Furthermore I have somewhere read in the documentation that
using custom event should go together with adding an embedded
statement like: [Event(name="update",
type="Components.UpdateEvent")] in the class where you use the
event, but for me it also works without this embedding code (???)
And is your class XMLData a subclass from a class that
supports dispatchEvent. I do not know what classes support
dispatchEvent, maybe all. Then this remark makes no sense.
Good Lcuk -
Could i use page unload event in Class Library (Web part)?
Hi,
I am creating Web Part using visual studio class library. I am going to deploy it in SharePoint environment.
I want to do some functionality while page unload. Is there anything like that?
Could anyone tell about it?
Thanks & Regards
Poomani SankaranHi,
According to your description, my understanding is that you want to create a web part programmatically and then do some functionality in the page unload event.
There is a web part method called WebPart.OnUnload method, you can override this method and add the custom code to the override method.
Here are some detailed articles for your reference:
https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.onunload(v=office.14).aspx
http://www.codeproject.com/Articles/25019/Developing-SharePoint-WebParts
Thanks
Best Regards
Jerry Guo
TechNet Community Support -
Configure event of class to trigger workflow...
Hi,
When a material is created, the standard event CREATED gets triggered of BO 'BUS1001006'.
But my client wants everything to be handled based on classes.
So i have created a custom class and its custom event 'CREATED' which needs to be triggered once a material is created.
So my question is how will i trigger this custom event of custom class. Is there any configuration that needs to be done for the same?
For now, i am planning to trigger the custom event in a BADI or user exit using standard FM 'SAP_WAPI_CREATE_EVENT'.
Kindly suggest your ideas.
Regards,
GuddanHi- My suggestion is, let the WF be triggered using std BO and event. For additional custom methods, you create a new WF based class
Also you need to decide, is it required to create an instance for the class (for instance method)
Vinoth -
Hi All,
I would like to know if events (instance/static) can be raised within class constructors. My understanding is that events can be raised but not of the same class as the class constructor belongs to.
Please clarify.
Thanks and Regards,
Vidya.Hi Vidya,
Welcome to SDN.
see this link
http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4eca79e11d1950f0000e82de14a/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/0a/b552f7d30911d2b467006094192fe3/frameset.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/41/7af4eca79e11d1950f0000e82de14a/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for Implementing constructor outside class implementation..
use this code
codeREPORT zkarthik.
CLASS counter DEFINITION
CLASS counter DEFINITION.
PUBLIC SECTION.
*METHODS CONSTRUCTOR.
CLASS-METHODS: set IMPORTING value(set_value) TYPE i,
increment,
get EXPORTING value(get_value) TYPE i.
PRIVATE SECTION.
CLASS-DATA count TYPE i.
NO explicit constructor
*METHOD CONSTRUCTOR.
*WRITE:/ 'I AM CONSTRUCTOR DUDE'.
*ENDMETHOD.
ENDCLASS. "counter DEFINITION
CLASS counter IMPLEMENTATION
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD. "set
METHOD get.
ENDMETHOD. "get
METHOD increment.
ENDMETHOD. "increment
ENDCLASS. "counter IMPLEMENTATION
DATA cnt TYPE REF TO counter.
START-OF-SELECTION.
Implicit constructor is called
CREATE OBJECT cnt.
CALL METHOD counter=>set
EXPORTING
set_value = 5.
END-OF-SELECTION.[/code]
happy learning.
thanks
karthik -
About events of class cl_gui_alv_grid
When the following two event gets trigger in execution.
I mean by clicking what they get trigger or how we can triger them and how to use them.
menu_button
data_changed
In general how one can understand that which event will be triigered when from the class event.Hello Amit
In order to understand the event DATA_CHANGED in more detail you may have a look at Get edited data ou of grid back into internal tabel
and the links provided therein (in particular my discussion with David Halitsky).
Regards
Uwe -
Hi, I'm trying to get a grip on writing classes. I have a
simple preloader class which sort of works. When I trace
_percentLoaded from within the class the percentages are output
when I add the class to an fla. But, if I trace _percentLoaded from
the fla I get NaN. Is there a way to pass the progress event data
into the fla? Thanksright, it's a little tricky. Offhand, you could choose from:
- place the event handler function on the main timeline (it
doesn't have to be in the same class)
- from within your class, create a dynamic handler function
on the timeline (which might be a pain)
- callback to the timeline with the data
- from within the present handler, broadcast a custom event
that gets handled in the main timeline
the communication might require instantiating like so:
new SimpleLoader(this)
from the main timeline so that your instance could then refer
back to the main timeline
which is the reverse of what you'd normally think of:
var loader:SimpleLoader = new SimpleLoader()
so that the loader can be accessed from the main timeline via
the var "loader". -
Controlling events between classes
hello
i know i'm asking a lot, but i couldn't find anything. the problem is i've got a jframe and some panels with buttons.
eg:
class A extends JFrame
getContentPane().add( B ) ;
getContentPane().add( C ) ;
class B extends JPanel
add( button1 ) ;
add( button2 ) ;
class C extends JPanel
add( button3 ) ;
add( button4 ) ;
where do i add ActionListeners? how do i pass information between classes? if button1 is clicked -> class A should know it.
i tried to do this in class A: objectOfB.button1 (access button1 directly) - didn't work - why?
if a button1 is clicked i want to remove the jpanel and replace it with another one. how should i do this?
Thank You AllCheck out the java tutorials. There are great examples that show you how to do what you want to do
-
Enhance standard class with event handler method
In trying to enhance a standard class with a new event handler class, I find that the ECC 6.0 EHP4 system does not appear to recognise the fact the method is an event handler method. The specific example is a new method to handle the event CL_GUI_ALV_GRID->USER_COMMAND.
I notice that the flag called Active has not been ticked - see image below. Perhaps this is the reason why the event handler is not being triggered.
Note that there is an event handler for the same event in the standard class which obviously is executed as expected. Any ideas on limitations in the system or I am missing a step?
Thanks
JohnThank you for your replies.
There is a bug in the ALV handler of a standard SAP class (when executed in ITS WebGUI) and I was hoping to create a custom event handler as an Enhancement to execute some custom code to sort of "handle the bug".
I agree - ideally it should be done in a Z class but that will not give me access to the object methods and attributes of the enhanced class.
Cheers,
John -
WF: Problem in raising event of a class in ABAP code to complete workitem.
Hi All,
I'm developing a workflow of Hiring Eform.
In this workflow we have created a step for some data processing and also set termination event for the task inorder to complete the task.
Now problem is that how to trigger the event of this class in the abap code so that the workitem will be completed.
As far as i know i have used following function module to raise a event for BOR. but is there any way to raise/trigger the event of Class.
For BOR: SAP_WAPI_CREATE_EVENT[Note 1322202|https://service.sap.com/sap/support/notes/1322202] provides SAP_WAPI_CREATE_EVENT_EXTENDED which can do classes.
-
Dear Support,
I run the AWR report. It show the top 5 event is class slave wait 70second then follow by CPU time. May i know what is class slave wait event. Thanks
Regard
William10g is a marketing label not a version number.
SELECT * FROM v$version;Don't describe the AWR report part your are seeing ... Ctrl-C then Ctrl-V ... and post it between tags so we can read it. -
Creating event dispatching in custom class
I have been trying to create an event dispatcher in a custom
data transfer object class. It's a simple class and I don't know
how to make it dispatch an event. I tried extending the
EventDispatcher class but that doesn't appear to work either. Any
help would be greatly appreciated.I have attached the code for the application and the custom
class. This should work from what I have read, but I can not get
the application to catch the event.
APPLICATION
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
creationComplete="initThis()" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var _tester:TestClass = new TestClass();
private function initThis():void{
addEventListener(TestClass.TEST_ACTION, onTestHandler);
private function onTestHandler(event:Event):void{
Alert.show("Event Dispatched");
]]>
</mx:Script>
<mx:Button x="312" y="150" label="Button"
click="{_tester.testEvents()}"/>
</mx:Application>
CLASS
package
import flash.events.EventDispatcher;
import flash.events.Event;
public class TestClass extends EventDispatcher
public static const TEST_ACTION:String = "test";
public function testEvents():void{
dispatchEvent(new Event(TestClass.TEST_ACTION));
}
Maybe you are looking for
-
XML Payload Validator SAP PI 7.1
Boas Estou com um problema em um interface, mais propriamente em um campo do mesmo que é um string (50). E este campo esta a ser enviado com 51 caracteres, e mesmo assim o PI aceita sem qualquer tipo de validação anterior, o que vai gerar um dump na
-
Itunes wont connect to store!
Hey, Iv recently downloaded itunes for the 1st time as my partners just upgraded to an iphone4. I seem to be having trouble connecting to the itunes store Iv tried everything thats been suggested and what iv read on google but nothing seems to be wor
-
Hi, Are there are any standard reports (regarding employee,assignment details etc..) available as seeded in Oracle? The only ones I could see are the EEO reporting. Thanks Usha.
-
TIFF compression - how to disable?
Hello - I'm using InDesign CS3 at a newspaper. I paginate the paper and print to a PDF file that goes into hot folder, gets ripped through Xitron Harlequin RIP then goes to a Computer to Plate. I'm working on Windows XP. That's just some workflow bac
-
Personnel no. assignment.
Hello, I would like to know I want to keep personnel no. as per employee sub group does it possible? Yuvraj