Passing parameters to an event handler

I am successfully using event handlers to respond to user
inputs(mouse click, enter key, etc.)
The handler can also use the event objects parameters to
perform operations based on who called the function. An example of
this is the target._name, which is apparently passed when the event
occurs.
In addition, I have a need to call an event handler from
within AS to essentially mimic a mouse click or keyboard entry.
This call from AS is no problem. Just use the event handler
name. For instance, mc.click(); and the handler is invoked.
However, with the AS call there is no object passed to the
handler. This differs from an event-driven call where an object
identifying the event source is passed to the handler.
The question is: Can you pass a parameter(s) or object to an
event handler from a call in ActionScript? I have tried various
ways, but nothing has worked.
Does anyone know the insides of event handling and how the
"eventObject" is passed when
a user event occurs? Knowing how that works might give some
clues as to how to pass an object from an AS call.

You would need to use a modified version of the
mx.utils.Delegate package. The link below has just that;
http://www.person13.com/articles/proxy/Proxy.htm

Similar Messages

  • How to pass params to Action Event handler in treeNode?

    Trying to use Tree in portlet I found impossible to determine selected node. (bug # 6354989).
    But I can (despite what is written in manual) use Action Event Handler. It works now (at least, I hope so).
    But I generate tree dynamically and cannot write event handlers for all its nodes. May be there's a way to write one event handler but distinguish node that triggered it? May be by passing additional params to handler?

    The tree component does not work well in portlets. This is a known problem.
    It uses cookies to pass the value of the selected node, but cookies do not work inside of portlets. So, the methods that would normally tell you which node is selected, return nothing. There are also no javascript properties which would allow you to output javascript to store the value somewhere in the page.
    Unfortunately there is no workaround for the bug you mentioned so far so far.
    Rose

  • Passing parameters based on events

    Hi,
    I want to pass the parameters between portlets on a
    particular event e.g. onClick() or onChange(). The example which
    is given in PDK is not useful in such a scenario. How can I use
    htmlFormActionLink in this case ?
    Thanks In Advance,
    - Chetan

    Chetan,
    You can use javascript to dynamically submit the form.
    Lets say you have a button (which is not submit button) and
    onClick event of it should pass some parameters to the portlet.
    <!-- Usual htmlFormActionLink -->
    <form name="custform" method="post"
    action="http://.../servlet/page">
    <!-- Hidden fields go here. -->
    <!-- Private parameters can be defined as
    hidden fields. -->
    <input type="button" name="ok" value="ok"
    onClick="javascript:document.custform.submit();">
    </form>

  • How to pass parameter (tray name) to event handler for Trays?

    Hi,
         I've several UI tray elements in my view and all these elements are associated with the action onToggleTrays.
         I want to capture the name of the Tray and state of tray(expanded/collapsed).
         For this when I try to add parameters to this event handler method, through IWD ParameterPassing, I can add only the expanded property. I'm not able to add the UI element (tray name).
         Can you please suggest how to add/pass tray name and tray state to the event handler method?
    Regards
    Sagar Nanda

    create a parameter for the action OnToggle say "id".
    In wdDoModifyView get the reference of tray element and map its id to this parameter.
    IWDTray tray=(IWDTray)view.getElement("Tray1");
    tray.mappingOfOnToggle().addParameter("id",tray.getId());
    IWDTray tray2=(IWDTray)view.getElement("Tray2");
    tray2.mappingOfOnToggle().addParameter("id",tray2.getId());
    Hope it helps.

  • Passing data to event handler function

    I am trying to pass value to the event handler function but I
    am getting the following error. Can someone please tell me what I
    am doing wrong?
    1067: Implicit coercion of a value of type void to an
    unrelated type function
    here is the code
    private function myClickListener(myid:int):void{
    Alert.show("The button was clicked");
    public function handleStringResult(event:ResultEvent):void{
    catInfo = event.result as ArrayCollection;
    for each(var o:Object in catInfo){
    var b:Button = new Button();
    b.label = o.FILLCOLOR;
    b.id=o.CATID;
    b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
    b.setStyle("color","#FFFFFF");
    b.setStyle("fontFamily","Arial");
    b.setStyle("fontSize",8);
    b.setStyle("textRollOverColor", "red");
    b.addEventListener(MouseEvent.CLICK,
    myClickListener(o.CATID));
    myvbox.addChild(b);
    ]]>

    "Merlyn MM" <[email protected]> wrote in
    message
    news:[email protected]...
    > Sure, Here is the code. I am very new to flex and if my
    code doesn't make
    > sense
    > then please let me know the correct way to do this. I
    really appreciate
    > you
    > taking time!
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    > layout="absolute"
    > backgroundColor="#FFFFFF"
    > initialize="myService.getcategories.send()">
    > <mx:WebService id="myService"
    > useProxy="false"
    > wsdl="
    http://devsite/rc/category.cfc?wsdl"
    > showBusyCursor="true">
    > <mx:operation name="getcategories"
    > result="handleStringResult(event)"
    > fault="Alert.show(event.fault.message)"/>
    > <mx:operation name="getsubcounties"
    result="handleStringResult(event)"
    > fault="Alert.show(event.fault.message)"/>
    > <mx:request>CATID</mx:request> //need to
    pass category ID here
    > </mx:operation>
    > </mx:WebService>
    >
    > <mx:Script>
    > <![CDATA[
    > import mx.collections.ArrayCollection;
    > import mx.rpc.events.ResultEvent;
    > import mx.rpc.events.FaultEvent;
    > import mx.controls.Alert;
    > import mx.controls.Button;
    >
    > [Bindable]
    > private var catInfo:ArrayCollection;
    >
    > private function myClickListener(myId:String):void{
    >
    > myService.getcounties.send() // I need to send catid
    here to the
    > webservice
    > }
    >
    >
    > public function
    handleStringResult(event:ResultEvent):void{
    > catInfo = event.result as ArrayCollection;
    > for each(var o:Object in catInfo){
    > var b:Button = new Button();
    > b.label = o.FILLCOLOR;
    > b.id='btn'+o.CATID;
    >
    >
    b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
    > b.setStyle("color","#FFFFFF");
    > b.setStyle("fontFamily","Arial");
    > b.setStyle("fontSize",8);
    > b.setStyle("textRollOverColor", "red");
    > b.addEventListener("click", myClickListener);
    > myvbox.addChild(b);
    > }
    > }
    > ]]>
    > </mx:Script>
    I'd change it to this:
    private function myClickListener(e:Event):void{
    //I don't see where you're using the ID, but to get it,
    //use this code:
    var myID = e.currentTarget.data;
    myService.getcounties.send() // I need to send catid here to
    the
    webservice
    public function handleStringResult(event:ResultEvent):void{
    catInfo = event.result as ArrayCollection;
    for each(var o:Object in catInfo){
    var b:Button = new Button();
    b.label = o.FILLCOLOR;
    //note that you couldn't have used your ID
    //as a "handle" to anything, so I replaced
    //that logic with something you _could_ use
    b.data=o.CATID;
    b.setStyle("fillColors",['#'+o.FILLCOLOR,'#'+o.FILLCOLOR]);
    b.setStyle("color","#FFFFFF");
    b.setStyle("fontFamily","Arial");
    b.setStyle("fontSize",8);
    b.setStyle("textRollOverColor", "red");
    b.addEventListener("click", myClickListener);
    myvbox.addChild(b);
    You could also use a Repeater and set this up in MXML.
    HTH;
    Amy

  • Error in event handler method in window

    Hi,
    I have created configuration in SEFVISU, to receive the workitem i have created a parameter in event handler method in window
    but it is throwing dump The ASSERT condition was violated, if i remove that parameter means application executing properly but i am not able to pass the unique, values please guide me.
    Regards,
    Srini.

    Hello Srini,
    are you talking about the default event handler method of the window? if so then you need to ensure that the parameter name defined in the event and passed in name are same. And also its better to go for the parameter type as STRING.
    other option would be instead of defining the static parameters in the event handler method, you can get the parameters from the WDEVENT itself by accessing WDEVENT->PARAMETERS table.
    hope this helps.
    BR, Saravanan

  • Portal Event Handler

    Hi,
    This is regarding passing portlet parameters to the event handler. Whenever an event is raised, I have been using a javascript function, which constructs the URL to the portal event handler and then submits the form. The url would look like
    http://host:port/portal/event?event_Param=xyz&_eventName_event1=event1
    (The query strings for dad, schema etc are not shown in the url above, but they are aslo passed).
    Is this the only way that one raises an event? Is there a method by which I can pass the the portlet parameters hidden in the request, so that they dont show up in the URL string?
    I tried doing a "POST" form submission, but the portal didnot respond to this action.
    Thanks.
    Jitendra

    Hi,
    As there is no such event for item published, we can detect the level of publication of the corresponding file using the
    SPFile.Level property in the ItemUpdated event, there will be three levels:
    Published, Draft, Checkout.
    Here is a code demo about how to check whether a file is published in ItemUpdated event:
    public override void ItemUpdated(SPItemEventProperties properties)
    base.ItemUpdated(properties);
    SPListItem item = properties.ListItem;
    SPFile file = item.File;
    //if the file is published
    if (file.Level == SPFileLevel.Published)
    Feel free to reply if there are still any questions.
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they
    help and unmark them if they provide no help. If you have feedback for TechNet
    Subscriber Support, contact [email protected]
    Patrick Liang
    TechNet Community Support

  • Pass parameters to a function in main class from loaded SWF?

    I've got a main.as that loads SWF to the stage.
    the loaded SWF seppoused to pass a link to the main.as and trigger a javascript function to popUp that photo from that link.
    I know there are two ways:
    ((root as MovieClip).parent.parent as Object).somefunction(parameters);
    and to dispatch an event.
    inorder to pass parameters throug the event i need to extend it with another class.
    isnt the (root as... )  more efficient if all i need is to pass a link?

    when a photo from the gallery is selected a javascript popUp shows it enlarged with additioan editing options (kinda like in facebook).
    in that popUp ther is also a next button so its kinda bidirectional. (the next calling the loaded SWF throug main to get the next link in the photo array)
    the photo is a grandchild of a grandchild of the stage and the loaded swf is a grandchild so using:
    ((root as MovieClip).root as MovieClip).ExternalInterface.call("ShowPic", link);
    is discusting ><

  • UIX-XML BC4J Question regarding event handling

    How can I use/access Application Module, defined in UIX-XML page (using <bc4j:registryDef>), in my event handler method ???

    Sorry for the confusion. I figured out what you were asking.
    The right way is this.
    First, in your UIX XML page, declare your handler like this:
    <event name="%myEvent%" >
    <bc4j:findRootAppModule name="%ModuleName%" >
    <method class="%eventclass%" method="%eventmethod%" />
    </bc4j:findRootAppModule>
    </event>
    the strings in the % have to be replaced with your own particular names. %ModuleName% should be the same as the name of the module in the registry.
    Then in the event handler %eventclass%.%eventmethod% you can use this to find the Application Module:
    oracle.jbo.ApplicationModule mymodule
    = oracle.cabo.data.servlet.bind.ServletBindingUtils.getApplicationModule(context);
    "context" is passed in to your event handler as a BajaContext. ServletBindingUtils has several other methods for getting BC4J stuff, you should look at its definition.
    Joe

  • Event Handler with parameters

    I am to create a generic event handler ro process XML
    returned from the server. Its name is this code is "loadFormData".
    Here is my code:
    var params:Object = new Object();
    params.requesttype = 'send';
    params.datarequest = 'xml';
    params.methodexecute = 'mProcessFileRequest';
    params.formname = "FileIdAction";
    params.fileid = parentApplication.cboFileList.id;
    var t:loadFileData = new loadFileData();
    xmlModuleData.addEventListener(ResultEvent.RESULT,
    t.loadFormData(ResultEvent, frmGeneral));
    var r:runXML = new runXML();
    r.getXMLData(xmlModuleData, params);
    It would work if I dont send any parameters to
    t.loadFormData. But then it is not a generic solution. Is it
    possible to send parameters to a callback function?
    Thanks

    Thanks Charlie
    Liao
    and congrats to all :-)
    * Charlie,
    is there a new "Auto Spam Filter"?
    [Personal Site] [Blog] [Facebook]

  • Can any bady send the WDJ application on event handler & plug  parameters?

    Hi,
    Experts,
    I have no idea no WDJ Event handler and plug parameters usage if any bady can send me few WDJ application or scenarios which is based on event handler parameters and plug parameters and method parameters. 
    Thans in advance,
    Shaber Ahmed.

    Hi
    Use this pdf(Example) for event handler
    http://www.sappro.com/downloads/WebDynproJava.pdf
    for plug parameters usage
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/91b6ad90-0201-0010-efa3-9626d2685b6e?overridelayout=true
    Thanks

  • Passing parameters for events

    Hi,
    I have a lot of buttons in my jsp page.. I would like to use the same event handler for all of them.. differentiating which one is clicked by means of a parameter.. How do i pass somthin like tat ....!
    Any hints !
    Regards
    Bharathwaj

    Hi,
    I guess you dont get it yet !
    In WebDynpro we have an option of adding a parameter as a argument with the Event.
    (like public void onText(Event event,String myParameter)
    Considering your case ..Assuming i dont want to use the button id .. how will i acheive this !
    This is the requirement i am looking in ..What you are suggesting is using the id and manipulating values..
    Regards
    Bharathwaj

  • Can  DISABLE preProcess Event Handler add to the Orchestration parameters?

    I have a DISABLE pre-process event handler defined on the User object. I need to set the current date on a USR UDF attribute whenever the user is disabled or enabled or created. The CREATE handler works and the date value shows up on the user profile. However, when I try to set this attribute on the pre-process DISABLE or ENABLE event handlers, the new date does not show up. Here is the code I am using in my DISABLE/ENABLE event handler:
    Date currentTime = new Date(System.currentTimeMillis());
    orchestration.addParameter(USER_STATUS_DATETIME_ATTR_NAME, currentTime);
    Where the orchestration object is from the execute() parameter list.
    Any ideas as to why this is not working? Is adding to the orchestration not allowed for DISABLE or ENABLE event handlers? I know my handler is getting calls as I am logging the orchestration.getOperation() value.
    Thanks for any suggestions.
    -Dave
    Edited by: user552098 on Nov 12, 2012 1:56 PM

    When you update the field, make sure you are using the field label name, and not the UDF value.
    -Kevin

  • Passing an array into an Event Handler?

    An inventory project I am working on is requiring me to create JButtons (First, Last, Next, and Previous) which are supposed to cycle through and display (in JTextFields) the contents of an array of objects. I can make the buttons work if I do this:
    numberfield.setText("This works when used in the event handler");
    but it does not work when I try to do this:
    numberfield.setText(dirtbikes[0].getNumber());
    When I try this, I get this error:
    InventoryGUITest2:java:124:cannot find symbol
    symbol : variable dirtbikes
    location : class InventoryGUITest2
    numberfield.setText(dirtbikes[0].getNumber());
    ^
    I'm not sure if what I am trying to do is possible, but any guidance would be greatly appreciated. I have included the code for the main class below. Thank you for your time.
    import javax.swing.*; // imports all javax.swing classes
    import java.awt.event.*; // imports event handling components
    import java.awt.*;
    public class InventoryGUITest2 extends JFrame implements ActionListener // class tests an instance of class Inventory using a GUI to display data
         JTextArea textArea;
         JLabel numberlabel, namelabel, speedlabel, pricelabel, stocklabel, restocklabel, valuelabel, totalvaluelabel; // creates JLabels
         JTextField numberfield, namefield, speedfield, pricefield, stockfield, restockfield, valuefield, totalvaluefield; // creates JTextFields
         JButton firstbutton, lastbutton, previousbutton, nextbutton; // creates JButtons for navigation
         public static void main( String args[] ) // begins Java execution
              Dirtbikes dirtbikes[]; // declares array variable
            dirtbikes = new Dirtbikes[4]; //declares array with length of 4
            // populate array
              dirtbikes[0] = new Dirtbikes( "11", "49cc Dirt Bike", 4, 199.99, "25 mph"  );
              dirtbikes[1] = new Dirtbikes( "12", "90cc MotoX Bike", 7, 1299.99, "45+ mph" );
              dirtbikes[2] = new Dirtbikes( "13", "70cc Pit Bike", 3, 359.99, "35+ mph" );
              dirtbikes[3] = new Dirtbikes( "14", "50cc Street Rocket", 5, 879.99, "55+ mph" );
            // end populate array
            new InventoryGUITest2(dirtbikes); // creates new instance of itself
         } // end main method
        // constructor creates and runs GUI
         public InventoryGUITest2(Dirtbikes[] dirtbikes)
            this.setSize(500,300);
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setTitle("Dirt Bike Inventory");
              JPanel panel1 = new JPanel(); // creates panel to imbed buttons into bottom of frame
              firstbutton = new JButton("First");
              firstbutton.addActionListener(this);
              panel1.add(firstbutton);
            lastbutton = new JButton("Last");
            lastbutton.addActionListener(this);
            panel1.add(lastbutton);
            previousbutton = new JButton("Previous");
            previousbutton.addActionListener(this);
            panel1.add(previousbutton);
            nextbutton = new JButton("Next");
            nextbutton.addActionListener(this);
            panel1.add(nextbutton);
            this.add(panel1, BorderLayout.SOUTH);
            JPanel panel2 = new JPanel(); // creates panel to imbed labels and fields into frame
            panel2.setLayout(new FlowLayout(FlowLayout.RIGHT));
            numberlabel = new JLabel("Item Number:                                      ");
            numberfield = new JTextField(25);
            numberfield.setEditable(false);
            panel2.add(numberlabel);
            panel2.add(numberfield);
            namelabel = new JLabel("Item Name:                                          ");
            namefield = new JTextField(25);
            namefield.setEditable(false);
            panel2.add(namelabel);
            panel2.add(namefield);
            speedlabel = new JLabel("Top Speed:                                           ");
            speedfield = new JTextField(25);
            speedfield.setEditable(false);
            panel2.add(speedlabel);
            panel2.add(speedfield);
            pricelabel = new JLabel("Price:                                                     ");
            pricefield = new JTextField(25);
            pricefield.setEditable(false);
            panel2.add(pricelabel);
            panel2.add(pricefield);
            stocklabel = new JLabel("# in Stock:                                            ");
            stockfield = new JTextField(25);
            stockfield.setEditable(false);
            panel2.add(stocklabel);
            panel2.add(stockfield);
            restocklabel = new JLabel("Restock Fee (5%):                              ");
            restockfield = new JTextField(25);
            restockfield.setEditable(false);
            panel2.add(restocklabel);
            panel2.add(restockfield);
            valuelabel = new JLabel("Total Value with fee:                          ");
            valuefield = new JTextField(25);
            valuefield.setEditable(false);
            panel2.add(valuelabel);
            panel2.add(valuefield);
            totalvaluelabel = new JLabel("Total Value with fee (for all items):");
            totalvaluefield = new JTextField(25);
            totalvaluefield.setEditable(false);
            panel2.add(totalvaluelabel);
            panel2.add(totalvaluefield);
            this.add(panel2);
            this.setVisible(true); // makes frame visible
              this.setLocationRelativeTo(null); // centers window on screen
         } // end constructor
                   public void actionPerformed(ActionEvent e)
                        if (e.getSource() == firstbutton)
                             numberfield.setText(dirtbikes[0].getNumber());
                   }

    bwilde wrote:
    I appreciate the help as everything I thought I had learned about Java has seemed to fall by the wayside in the shadow of making Swing/AWT work properly.You're not the first person to write this, or code like this in the forum. But realize it isn't true. GUI coding isn't a special case -- it's just another example of object-oriented programming. What's really happening is that the training wheels have come off: Writing a simple Swing example is often the first time one is writing anything that is not trivial.

  • Getting Error in Crystal report While passing parameters (DB: MS ACCESS)

    I have been trying to solve passing parameters in Crystal Reports.
    What I have done is :
    I added Crystal Reports to my project,
    I connect to database using OLE DB (ADO) in database expert form (for your kind information; I did not create or add DataSet1.xsd file the Crystal Reports worked on below code with out parameters and I want report with parameter)
    I added below piece of code on my form load event
    When I try to pass parameter using .SetparameterValue function, report pop up with bunch of values BUT it does not filter with values which I want, Can anyone tell me that Am I missing something strange ? If yes please guide me
    Here is images Links : Dropbox - Creport error
    First Image shows my crystal report look, second image shows my DB connection and third one shows the error which I am getting while executing below code
    Please help me, I've been trying to solve this problem for two months.
    Public Class frmrptProducts
       Private Sub frmrptProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim cryRpt As New ReportDocument
       Dim CrTables As Tables
       Dim crtableLogoninfo As New TableLogOnInfo
       Dim crConnectionInfo As New ConnectionInfo
       'load report
      cryRpt.Load(ReportPath & "CRproducts.rpt")
       'parameters definition(if any) This is the part where I pass parameters
       Dim ColourName As String = "White"
      cryRpt.SetParameterValue("colours", ColourName)
       'provide connection info. This is important and you can change it as per your db location
       With crConnectionInfo
       .ServerName = My.Application.Info.DirectoryPath.ToString() & "\data\db.mdb"
       '.DatabaseName = ""
       '.UserID = ""
       .Password = ""
       End With
      CrTables = cryRpt.Database.Tables
       For Each CrTable In CrTables
      crtableLogoninfo = CrTable.LogOnInfo
      crtableLogoninfo.ConnectionInfo = crConnectionInfo
      CrTable.ApplyLogOnInfo(crtableLogoninfo)
       Next
      CRV.ReportSource = cryRpt
      CRV.Refresh()
       End Sub

    HI Don,
    Thanks for replied, I have come up with some different code and it worked,
    Please visit this link and let me know if Am I able to get question resolved Pass more than two parameters to Crystal Reports from VB.NET

Maybe you are looking for