Custom events for custom classes
So what I'm trying to build is a custom class wich connects
to a php socket server using an XML socket.
I don't know how I can broadcast an event so I can write
something like the code below. Anyone can help ?
To be more specific my class looks something like this
:
Similar Messages
-
Registering event as application event for local class inheriting grid clas
hello all,
i have a scenario where i have to use many events as system events and one event as a application event for a local class defined which inherits cl_gui_alv_grid can any one tell me how exactly could i do it.
Thanks,
raju NHello Uwe,
Each of them- "Dynpro" and "Programs" has 2 entries:
Dynpro 0100 Müller
0200 Harryhirsch
Programs SAPTROX1
SAPTRIXTROX
How can you say that "Programs" has children and "Dynpros" not?
Regards,
Christian -
AT LINE SELECTION FOR STANDARD CLASSES
hi...im developing a report in which i used CL_DOPR_WRITER class to create a table..how can i write AT LINE SELECTION EVENT for this class.
follow this in your code:
AT LINE-SELECTION.
PERFORM F1.
<<<<f1
form f1.
if you want to call any static attribute or method just do
CL_DOPR_WRITER=>method or parameter
but if you want to access pubic method or att
ref type refrence of CL_DOPR_WRITER
call method ref->your method
endform. -
Problem of trigger event for Customer master.
Hi all,
I created one object type in KNA1. because i want to use task instead of the workflow.
after i executed the customer master creation , i got this error during the execution."Dereferencing of the NULL reference".
if anybody want information, please let me know.
Regards,
LukeHi
"At the beginning, i am using the Receiver Function module is SWW_WI_CREATE_VIA_EVENT.
after i change to "SAP_WAPI_CREATE_EVENT" but got error too."
Can you tell us where are you calling this FM (is it via Enhancement option or badi or exit) to trigger the event?
Just leave the Receiver FM as same as in SWE2 and make sure Linkage Actiavted check box is checked
"i can't do the buiding between &EVT_OBJECT& and &WI_OBJECT_ID&. because it is not same business object.
for our workflow object, it references to class is developed by me.
As suggested by Rick, you could make use of FM or as per blog, you could use class to trigger your custom class's event. Then you need to have binding at task level (PFTC)
&EVT_OBJECT& --> &WI_OBJECT_ID&.
Vinoth -
Need help with custom event from Main class to an unrelated class.
Hey guys,
I'm new to Flash and not great with OOP. I've made it pretty far with google and lurking, but I've been pulling my hair out on this problem for a day and everything I try throws an error or simply doesn't hit the listener.
I'm trying to get my Main class to send a custom event to an unrelated class called BigIcon. The rest of the code works fine, it's just the addEventListener and dispatchEvent that isn't working.
I've put in the relevant code in below. Let me know if anything else is needed to troubleshoot. Thank you!
Main.as
package
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip
var iconLayer_mc:MovieClip = new MovieClip();
public function Main()
Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
addChildAt(iconLayer_mc,0);
placeIcons();
function placeIcons():void
var i:int;
var j:int;
for (i = 0; i < 4; i++)
for (j = 0; j < 5; j++)
//iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i,j);
iconLayer_mc.addChild(placedIcon_mc);
function fl_MouseClickHandler(event:MouseEvent):void
dispatchEvent(new Event("twitchupEvent",true));
BigIcon.as
package
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.getDefinitionByName;
public class BigIcon extends MovieClip
private var iconImage_str:String;
private var iconRow_int:int;
private var iconColumn_int:int;
public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
iconImage_str = iconImage_arg;
iconRow_int = iconRow_arg;
iconColumn_int = iconColumn_arg;
this.addEventListener(Event.ADDED_TO_STAGE, Setup);
function Setup(e:Event)
this.y = iconRow_int;
this.x = iconColumn_int;
var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
var thisIcon_mc:MovieClip = new ClassReference;
this.addChild(thisIcon_mc);
addEventListener("twitchupEvent", twitchUp);
function twitchUp(e:Event)
this.y += 10;Ned Murphy wrote:
You should be getting an error for the Main.as class due to missing a line to import the Event class...
import flash.events.Event;
My apologies, I should attempt to compile my example code before I ask for help...
Alright, this compiles, gives me no errors, shows my 'book' and 'flowers' icons perfectly when ran, and prints 'addEventListener' to the output window as expected. I get no errors when I press the button, 'dispatchEvent' is output (good), but the 'twitchUp' function is never called and 'EventTriggered' is never output.
How do I get the 'twitchUp' event to trigger?
Main.as
package
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.*;
public class Main extends MovieClip
var iconLayer_mc:MovieClip = new MovieClip();
var iconString_array:Array = new Array(2);
public function Main()
Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
addChildAt(iconLayer_mc,0);
buildStringArray();
placeIcons();
function buildStringArray():void
var i:int;
var j:int;
for (i = 0; i < 2; i++)
iconString_array[i] = new Array(3);
for (j = 0; j < 3; j++)
if (Math.random() > .5)
//'flowers' is the name of an illustrator object that has been converted to a MovieClip and is in the library
iconString_array[i][j] = "flowers";
else
//'book' is the name of an illustrator object that has been converted to a MovieClip and is in the library
iconString_array[i][j] = "book";
function placeIcons():void
var i:int;
var j:int;
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
//iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i*50,j*50);
iconLayer_mc.addChild(placedIcon_mc);
function fl_MouseClickHandler(event:MouseEvent):void
dispatchEvent(new Event("twitchupEvent",true));
trace("dispatchEvent");
BigIcon.as
package
import flash.display.MovieClip;
import flash.events.*;
import flash.utils.getDefinitionByName;
public class BigIcon extends MovieClip
private var iconImage_str:String;
private var iconRow_int:int;
private var iconColumn_int:int;
public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
iconImage_str = iconImage_arg;
iconRow_int = iconRow_arg;
iconColumn_int = iconColumn_arg;
this.addEventListener(Event.ADDED_TO_STAGE, Setup);
function Setup(e:Event)
this.y = iconRow_int;
this.x = iconColumn_int;
var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
var thisIcon_mc:MovieClip = new ClassReference;
this.addChild(thisIcon_mc);
addEventListener("twitchupEvent", twitchUp);
trace("addEventListener");
function twitchUp(e:Event)
this.y += 10;
trace("EventTriggered");
Output:
[SWF] Untitled-1.swf - 40457 bytes after decompression
addEventListener
addEventListener
addEventListener
addEventListener
addEventListener
addEventListener
dispatchEvent
[UnloadSWF] Untitled-1.swf
Test Movie terminated. -
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));
} -
Listening to event within custom class
I've created a custom class that posts to a web page to authorize a user. How can I listen for an event within the custom class?
This is my code within my main class.
var customClass:CustomClass = new CustomClass();
var testingString = customClass.authorize("[email protected]", "password");
the fuction "authorize" within the customClass looks like this:
public function authorize(user:String, password:String):void
jSession = new URLVariables();
j_Loader = new URLLoader();
jSession.j_username = user;
jSession.j_password = password;
jSend.method = URLRequestMethod.POST;
jSend.data = jSession
j_Loader.load(jSend)
How can I fire an event within my main class once the j_Loader triggers Event.COMPLETE?You can fire an event using the dispatchEvent() function.
In your main class you assign a listener for the event the CustomClass dispatches after it exists. -
How to register mouselistener for custom class?
i m trying to create a custom class (extending java.awt.Rectangle)which responds to mouse gestures.
i m using it as an object on my drawpad which responds to mouse behavior
like rollover.
the rollover color change is achieved using canvas' graphics object triggerd by my cutom class
i m not able to register a mouseevent for the custom class.
can someone help me in achieving this?
thanks in advance
z_idaneSomething like this? Don't think I'd be likely to extend Rectangle, myself, but anyway...
public class HotSpot extends Rectangle implements MouseMotionListener
private boolean hover = false;
// add constructors to taste
public void mouseMoved(MouseEvent e)
if (this.hover != (contains(e.getX(), e.getY())
this.hover = ! this.hover;
if (this.hover)
// "mouse enter" code here
else
// "mouse exit" code here
public void mouseDragged(MouseEvent e)
}Obviously you'd need something like this elsewhere,
myDrawingPad.addMouseMotionListener(new HotSpot(...)); -
Adding info blocks in a custom class for Factsheet
Hi Experts,
I need to create a custom class by copying the standard class 'CL_CRM_CCKPT_PROCESS_OPEN' which should accept input as Activity Types. At present this class only accepts Number of months as Input. This added input field should accept individual multiple values & Ranges and F4 help also needs to be attached for the field.
I would like to know how to add this new input field to the class 'CL_CRM_CCKPT_PROCESS_OPEN' .
Any valuable help would be appreciated & points would be rewarded generously for the same.
Regards,
Sangeeta.Hi,
You can copy and include your fields in the class using transaction SE24.
According to your subject line you are trying to modify an existing factsheet display you own data. I would suggest instead of creating a modifying an existing class, implement your own function module and call this function module directly from the smartform used to for factsheet. This is an easier way to implement modification of factsheets instead of using the classes and displaying the data.
Reward with points if this helps.
Regards,
Gaurav Gera -
I'm creating a custom class to retrieve some data using URLoader.
My code is below, doing this from memory, plz ignore any minor typos.
The challenge I'm encountering: when my custom class calls the loader, the event handler takes over. At which point the context of my code leaves the function and it's not clear to me how I then return the data retrieved by the loader. I sense that I'm breaking the rules of how ActionScript really runs by putting a loader in a separate class; at least, that's my primitive understanding based upon the reading I've done on this.
So can I do this? I am trying to create a clean separation of concerns in my program so that my main program doesn't get clogged up with code concerned with retrieving remote data.
Thanks!
Main program;
import bethesda.myLoader;
var ldr:myLoader = new myLoader;
var data:String = myLoader.getData("someurl");
My custom class:
package bethesda {
public class myLoader {
function myLoader(url:String):String {
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest(url);
loader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void {
var ld:URLLoader = new URLLoader(event.target);
data = loader.load(); // here's where I don't know what to do to get the data back to my main programI think you are on the right track in abstracting loading from other code.
Your class may be like that:
package
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class myLoader extends EventDispatcher
// declare varaibles in the header
private var loader:URLLoader;
private var url:String;
public function myLoader(url:String)
this.url = url;
public function load():void {
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest(url);
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);
private function completeHandler(e:Event):void
dispatchEvent(new Event(Event.COMPLETE));
public function get data():*{
return loader.data;
Although, perhaps the best thing to do would be to make this class extend URLLoader. With the example above you can use the class as following:
import bethesda.myLoader;
import flash.events.Event;
var ldr:myLoader = new myLoader("someurl");
ldr.addEventListener(Event.COMPLETE, onLoadComplete);
ldr.load();
function onLoadComplete(e:Event):void {
var data:String = ldr.data; -
Terminating Event for BUS2017 Custom Method
Dear Experts,
I have an issue with the Terminating Event of the Workflow for BO : BUS2017. The event is getting triggered but receiver is not being picked.
I have created two events GR_103 and POST_105 in the Custom BO ZBUS2017 by delegating it to BUS2017. GR_103 is the triggering event for my workflow which I have triggered in the POST_DOCUMENT Method of the Implmentation for BADI : MB_MIGO_BADI.
GR_103 is triggered while doing MIGO (Goods Receipt) for Movement Type 103. My Workflow is triggered perfectly and then I have used a Dialog Asynchronous Task in which I have called the MIGO Transaction for Releasing the GR Blokced Stock using the Movement Type 105. I have created a Custom Method POST in the BO ZBUS2017 and I have used the FM: MIGO_DIALOG to call the MIGO. I am trying to raise the POST_105 event in the Method MB_DOCUMENT_BEFORE_UPDATE of the Interface IF_EX_MB_DOCUMENT_BADI. I have defined the Terminating Event for the asynchronous Task as POST_105.
Now the event POST_105 is triggered, but SWEL says 'No receiver entered'. Even the SWEINST shows the object data as the current Work Item along with Object Key, but still receiver not picked. When I try to trigger the same event in a test report by using call transaction, then the event triggers and work item gets completed without any issues.
Please advise.
Below is my terminating event code.
READ TABLE xmseg INTO wa_mseg INDEX 1.
CONCATENATE wa_mseg-mblnr wa_mseg-mjahr INTO l_objkey.
IF wa_mseg-bwart = '105' .
CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'BUS2017'
objkey = l_objkey
event = 'POST_105'
EXCEPTIONS
objtype_not_found = 1
OTHERS = 2.
ENDIF.
Regards,
Raju.Have a COMMIT WORK after the function call. (At least test it - I am not sure if it will have some effects in your BADI - at least you will know whether the issue is about missing commit).
And please use SAP_WAPI_CREATE_EVENT instead of the old function you are using.
Also, make sure that the events will look exactly the same in event monitor SWEL when triggered from your code and when using test tool. Maybe there is some minor difference/mistake (object key, etc.) that you haven't noticed.
Regards,
Karri
Edited by: Karri Kemppi on Feb 7, 2012 8:14 AM -
Unicode issue for custom CLASS
Hi Experts,
we have a custom CLASS 'Z_ADD_INN_SALES' as part of unicode conversion i have corrected all the unicode compliants found in the UCCHECK transaction associated with the CLASS and also marked unicode check in the properties of the class. But still it is saying it is not compatible for unicode. I am not able to activate the object because of this error. Kindly let me know whether i need to do any thing else which i have missed for unicode check.
Regards,
RamHello Ram
Apparently there is a coding-related Unicode error in the class. Check it with UCCHECK and analyze the error message.
For more details refer to:
[ABAP and Unicode|http://help.sap.com/saphelp_nw04/helpdata/en/62/3f2cadb35311d5993800508b6b8b11/content.htm]
Regards
Uwe -
Creating custom class instances for XML nodes
Hi guys,
I'm trying to load an external XML document in my application
and create an instance of a custom class for each node in the XML
based on the value of some of their elements. The instances created
will eventually end up in a DataGrid by the way. The problem I'm
having is there seems to be many ways of doing small parts of this
and I have no idea how to make them all gel. Initially I'm using
HTTPService to load the XML file but I've seen people just use an
XML object. Then, after that, I initially set the loaded XML to an
ArrayCollection but others have used XMLList or XMLListCollection.
I've no idea what's the best way to do this.
Eventually, when I've created all of these instances by
looping over the XML and creating them how will I make them
bindable to the data grid? I'm guessing I'll have to group them
somehow...
Any help would be greatly appreciated. ThanksHey Tracy,
That is exactly what I was talking about in a previous post
you replied to
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1344350
Anyhow, Below is some code I created to do what your saying
somewhat dynamically. The idea being you can have many different
object types that you may want to populate with data from XML. In
my case I am using e4x as the result type from my web services. At
present I have about 6 different classes that call this function.
I'd love to get some opinions on the function. Good bad or
???? Any improvements etc????
package . . . .
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import mx.utils.ObjectUtil;
* Utility class to convert xml based Objects to class
instances.
* Takes a value object as the destination and an xmlList of
data
* Look through all the items in the value object. Note we
are using classInfo..accessor since
* our objects are bound all variables become getter /
setter's or accessors.
* Also note, we can handle custom objects, arrays and
arrayCollections.
* History
* 03.11.2008 - Steven Rieger : Created class
public final class XMLToInstance
public static function xmlToInstance( destinationObject :
Object, sourceXMLList : XMLList ) : void
// Get the class definition in XML, from the passed in
object ( introspection so to speak )
var classInfo : XML = describeType( destinationObject );
// Loop through each variable defined in the class.
for each ( var aVar : XML in classInfo..accessor )
// If this is String, Number, etc. . . Just copy the data
into the destination object.
if( isSimple( aVar.@type ) )
destinationObject[aVar.@name] = sourceXMLList[aVar.@name];
else
// Dynamically create a class of the appropriate type
var className : String = aVar.@type;
var ObjectClass : Class = getDefinitionByName( className )
as Class;
var newDestObject : Object = Object( new ObjectClass());
// If this is a custom type
if( isCustomType( className ) && ObjectClass != null
// Recursively call itself passing in the custom data type
and the data to store in it.
// I haven't tested nested objects more than one level. I
suppose it should work.
// Note to self. Check.
xmlToInstance( newDestObject, sourceXMLList[aVar.@name] );
else
// Must be some sort of Array, Array Collection . . .
if( ObjectClass != null )
var anXMLList : XMLList = new XMLList(
sourceXMLList[aVar.@name] );
for each( var anItem : XML in anXMLList )
// I'm sure there are more types, just not using any of them
yet.
if( newDestObject is Array )
newDestObject.push( anItem )
else
newDestObject.addItem( anItem );
// Add the data to the destination object. . . .
destinationObject[aVar.@name] = newDestObject;
} // end function objectToInstance
public static function isSimple( dataType : String ) :
Boolean
* This function is pretty self explanatory.
* Check to see if this is a simple data type. Did I miss
any?
* History
* 03.11.2008 - Steven Rieger : Created function
switch( dataType.toLowerCase() )
case "number":
case "string":
case "boolean":
return true;
return false;
} // end isSimple
public static function isCustomType( className : String ) :
Boolean
* This function is pretty self explanatory.
* Check to see if this is a custom data type. Add them here
as you need. . .
* History
* 03.11.2008 - Steven Rieger : Created function
var aClassName : String = className.replace( "::", "."
).toLowerCase();
aClassName = aClassName.substr( aClassName.lastIndexOf( "."
) + 1, aClassName.length - aClassName.lastIndexOf( "." ) );
switch( aClassName )
case "ndatetimevo":
case "expenselineitemvo":
return true;
return false;
} // end isCustomType
} // end class
} // end package -
Custom class type for Plant material
Is there any way to create a custom class type for plant and material? Any other way to use standard functionality to use classification in material master for specific plan will also work.
thanks,Hi Rahul,
The Classification data in material master can only be maintianed at Client level and not at plant level.
The standard Class type 001 can be used to create your own classes. Create a class for each applicable plant. Add the applicable characterstics under every class. That way you will be able to maintain plant spceific details when you are adding Objects for the material master.
Regards,
kathir -
Creating a Custom event for my Component
Hi All,
im currently working in a swing component, and i would like to know how to give to my component the ability to react to some user changes.
Basically im creating a DateTime Picker using NetBeans, im able to see any new property justed created on the Property Editor but i would like to know how to add my custom events on the Event Editor as well, i.e:
monthChanged - (when the user just change the month dropdown)
yearChanged - (when the user just change the year box)
dayChanged - (when the user just change the selection day)
Thanks in advanceThanks, i just found it also here:
http://www.exampledepot.com/egs/java.util/CustEvent.html
i need to define the following class:
- Custom Listener extending the EventListener interface
- Custom Event extending EventObject class
and then finally add the corresponding:
addXXXListener
removeXXXListener
fireXXXEvent
in my component.
This work Great in the NetBeans GUI Builder.
Thanks,
Maybe you are looking for
-
Legacy project vs new browsers
Hi all, I have one client project for whom we still use TCS1, for updates about twice a year. This is the only client we use it for, so we have never upgraded. We do have a copy of RH10 standalone, but otherwise we have been increasingly using Flare
-
Photos that I have uploaded to my PC do not appear on my iPad. It worked once and no longer works. I have selected the appropriate folder on my PC in the icloud control panel options. Photos that I take on my iPad appear on my PC so I know icloud i
-
Frustrated, trying to find an itunes that will work with my OS!!!!
Does anyone know where I can get an itunes that is compatible with Tiger 10.4.2? I had itunes 7.?? working just fine and I upgraded to a point where it would not work anymore. I've tried finding older downloads, ie 6.0.5 and 7.7 but none of them work
-
Hi all, Actually client 100 is created in Production .while installation in java engine its through some error, we are not able to continue the installation & we are not able to connect the jave engine with client 100.So that we created the new clien
-
Update a Datagrid Automatically
I have created a datagrid and a button that refreshes the data in the grid from the database. What I'd like to do is automate this, so that I do not need to press the button , and the grid updates every few seconds. Does anyone know how to do this? I