Hi..handling events in console applications

Hi,
Can anyone tell me how to handle events in cosole applications...
I want to trap the event when a user closes the the console window....
THANKS IN ADVANCE
Rama

Hi,
No, I don't think so. A console application can only read from standard input (and you can read the return key that way). But I don't think that you can detect if ctrl is held down by a user, I think you need an UI for that, but I'm not 100% sure since I haven't had the need for it.
/Kaj

Similar Messages

  • Handling events in BSP application using WML tag Extensions

    Hello Everyone  ,
                            We are developing a BSP applications for Mobile handheld using WML tag library. I am looking for some code samples to know how we can handle evevents inside the BSP using the WML tag library.
    Can any one of  you plesae help us by placing a code snippet for handling onInputprocessing() methods (BSP Using WML Tag extensions).
    I mean to ask how we can handle events inside the BSP applications that uses the WML tag library.
    I know about how to handle BSP events using HTMLB and XHTMLB tags frameworks.
    Thanks for your help in advance.
    Thanks,
    Greetson

    Is this WML tag library something that is supplied by SAP u2013 as a BSP Extension Element?  Or are you just using WML tags directly in your layout?  I can tell you in general that if you want to generate HTMLB events from regular HTML code you can generate the JavaScript calls using the htmlbEvent tag of the BSP extension library.  However your tags have to be running within an HTMLB Content tag for this to work.
    If you want to work totally without HTMLB then you need to use the simple HTTP Post but format the input name as OnInputProcessing(<function code>) like this:
    <input type="submit" name="OnInputProcessing(ok)" value="OK">
    This will cause the OnInputProcessing event handler to trigger without needing any HTMLB tags (this is how it was done in WebAS 6.10 before we BSP Extensions).

  • How to handle events in Swng

    Hi!
    I would like to know which one of the following is the best way to handle events in Swing application.
    Method 1
    Write annonymus inner classes in the same class
    Method 2
    =======
    Write a seperate class which extends the adapter class of the event handling and create an object of that in the main class and assign it to the components with addActionHandler() method.
    I am trying to use the second one and I have the following design issue.
    I have a class frmMain.java in which I have a frame and to that frame I am adding a panel which consists of 'N' No. of components.
    I want to make this panel added to the frame when I click on a menu item (login) and want to remove the panel from frame when I click on a menu item(logout).
    I have a main class called Application.java where I create the object of my frame(frmMain.java).
    Thanks in advance,
    AV

    1. Your JFrame is now subject to receive action events from anywhere. You will have to be more careful that you respond only to the right events.
    2. If you have a lot of possible consequences to an event(for example, based on button pressed), you'll need a long if...then...else statement to determine what to do based on the source of the event.
    3. With individual ActionListener classes, it's easier to add the same listener to multiple components and no need to worry about source.
    4. Kind of the same thing: With individual classes, the event and its consequences are so tightly coupled.
    End preaching....basically, my style boils down to what I call the tool set vs Swiss army knife rule. Java seems designed around the concept of a large number of specific purpose classes vs a smaller number of multi purpose classes and I think its a design methodology that makes sense, because I believe strongly in functional isolation in my code.

  • Can't access community members list in event receiver when item is updated in console application

    Hi,
    we attached an event receiver to a list in a community site template. In the ItemUpdated event we access different lists from the site. Everything is working fine when we update a list item in the web frontend logged in as Administrator (application pool
    identity Administrator).
    Updating an list item in a console application running as Administrator triggers the ItemUpdated event and accesses all lists - only the Community Member list can't be accessed.
    SPWeb spWeb = properties.OpenWeb();
    Guid communityMembersListGuid = new Guid("3b56d08b-be6b-408b-a2aa-c08722ad499b");
    SPList communityMembersList = spWeb.Lists[communityMembersListGuid];
    We added the Administrator with full access to the list, run the code with RunWithElevatedPrivileges and initialized the spSite with the account-token of the administrator. Nothing works.
    Any idea?
    Greetings Peter

    Hi,
    Please try to use the following code blow:
    SPWeb spWeb = properties.Web;
    SPList communityMembersList = spWeb.Lists["Community Members"];
    If the issue still exists, I suggest you debug your code and provide the detail error message for further research.
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Code source works fine from console application but not from SharePoint interface

    Hi;
    Please can you help
    me to understand why my code below works fine from console application (VS 2010) and not working from interface of my SharePoint collection site :
    From console application : the subsite is created and I can to open without any problem
    From Sharepoint GUI : the subsite is created but impossible
    to open subsite : error 404 page not found ?
    The subsite creation is very long (2 minutes) and in concole application When I try to open the subsite just after its creation I have page not found and I must waits (several refresh) more time to open the subsite correctly.
    Can be I must to display a PoPup to show the progress creation ?
    using System;
    using System.Security.Permissions;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Security;
    using Microsoft.SharePoint.Utilities;
    using Microsoft.SharePoint.Workflow;
    namespace CreateSubSiteClients.EventReceiver1
        public class EventReceiver1 : SPItemEventReceiver
            public override void ItemAdded(SPItemEventProperties properties)
                     base.ItemAdded(properties);
                     try
                         SPWeb web = properties.OpenWeb();
                         if (properties.List.Title == "REFCLIENTS")
                             SPListItem curItem = properties.ListItem;
                             string name = properties.ListItem["SITE"].ToString();
                             curItem["SiteUrl"] = web.Url + "/" + name;
                             SPWeb rootWeb = web.Site.RootWeb;
                             SPWebTemplateCollection webTemplates = rootWeb.GetAvailableWebTemplates(1036);
                             SPWebTemplate webTemplate = null;
                             String webTemplateName = "ModeleSiteCourrier";
                             String webTemplateSearchName = "";
                             for (int i = 0; i < webTemplates.Count; i++)
                                 webTemplateSearchName = webTemplates[i].Name.ToString();
                                 if (webTemplateSearchName.Contains(webTemplateName))
                                     webTemplate = webTemplates[webTemplateSearchName];
                                     break;
                           SPWeb newSite = web.Webs.Add(name, name, name, Convert.ToUInt16(1036), webTemplate, false, false);
                            newSite.Navigation.UseShared = true;
                            newSite.Update();
                            newSite.Close();
                            Console.WriteLine("Le site suivant a été crée", name);
                     catch (Exception ex)
                         properties.Status = SPEventReceiverStatus.CancelWithError;
                         properties.ErrorMessage = ex.Message.ToString();
                         properties.Cancel = true;
    Regards

    Hi,
    To create subsite using event receiver in SharePoint Empty Project, you can refer to:
    Sharepoint 2010 event handler to create subsites
    To display a PoPup to show the progress creation, you can use:  MessageBox.Show("Hello, world.");
    More information:
    MessageBox.Show Method (String)
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Use sql notification for console application C#

    I have developed ucma C# console application which sends IM  to users. 
    Now I want to send IM if any new entry is added in the table 
    So i want to use query notification .
    I have enabled service broker on my database .
    And I have added code for sqldepedency  in my code file.
    as follows.
    public static void Main(string[] args)
    UCMASampleInstantMessagingCall ucmaSampleInstantMessagingCall =
    new UCMASampleInstantMessagingCall();
    ucmaSampleInstantMessagingCall.connectionfunction();
    public void connectionfunction()
    string connectionString = @"Data Source=PIXEL-IHANNAH2\PPINSTANCE;User ID=sqlPPUser;Password=ppuser1;Initial Catalog=Ian;";
    SqlDependency.Stop(connectionString);
    SqlConnection sqlConnection = new SqlConnection(connectionString);
    string statement = "select * from dbo.tblTest";
    SqlCommand sqlCommand = new SqlCommand(statement, sqlConnection);
    // Create and bind the SqlDependency object to the command object.
    SqlDependency dependency = new SqlDependency(sqlCommand, null, 0);
    SqlDependency.Start(connectionString);
    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
    private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
    ucmaSampleInstantMessagingCall.run()
    private void Run() { // Initialize and startup the platform. Exception ex = null; try { // Create the UserEndpoint _helper = new UCMASampleHelper(); _userendpoint = _helper.CreateEstablishedUserEndpoint();
    Now I want to run this application in the background , so f any new entry is added it will notify my C# application and call run function.
    i tried above code but it was not working.
    Sample code is avaliableon net but it is for form application and we can see output if we run the form application .
    so if i want to run my C# application what should I do?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Configuration;
    using System.Security.Principal;
    using System.Security.Cryptography.X509Certificates;
    using System.Net;
    using System.Threading;
    using System.Diagnostics;
    using Microsoft.Rtc.Collaboration;
    using Microsoft.Rtc.Signaling;
    using System.Runtime.InteropServices;
    //using Microsoft.Rtc.Collaboration.Sample.Common;
    namespace UserPresence
    class UCMASampleInstantMessagingCall
    #region Locals
    // The information for the conversation and the far end participant.
    // Subject of the conversation; will appear in the center of the title bar of the
    // conversation window if Microsoft Lync is the far end client.
    private static String _conversationSubject = "The Microsoft Lync Server!";
    // Priority of the conversation will appear in the left corner of the title bar of the
    // conversation window if Microsoft Lync is the far end client.
    private static String _conversationPriority = ConversationPriority.Urgent;
    // The Instant Message that will be sent to the far end.
    private static String _messageToSend = "Hello World! I am a bot, and will echo whatever you type. " +
    "Please send 'bye' to end this application.";
    private InstantMessagingCall _instantMessaging;
    private InstantMessagingFlow _instantMessagingFlow;
    //private ApplicationEndpoint _applicationEndpoint;
    private UserEndpoint _userendpoint;
    private UCMASampleHelper _helper;
    private static SqlDependency dependency;
    private static string connectionString = @"Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=SSPI";
    // Event to notify application main thread on completion of the sample.
    private AutoResetEvent _sampleCompletedEvent = new AutoResetEvent(false);
    #endregion
    #region Methods
    /// <summary>
    /// Instantiate and run the InstantMessagingCall quickstart.
    /// </summary>
    /// <param name="args">unused</param>
    //private string _helper;
    //UCMASampleHelper _helper = new UCMASampleHelper();
    public static void Main(string[] args)
    UCMASampleInstantMessagingCall ucmaSampleInstantMessagingCall =
    new UCMASampleInstantMessagingCall();
    var connection = new SqlConnection(connectionString);
    SqlDependency.Start(connectionString);
    SqlConnection connection = new SqlConnection(connectionString);
    connection.Open();
    SqlCommand command = new SqlCommand(
    "select col1 from dbo.tblTest",
    connection);
    // Create a dependency (class member) and associate it with the command.
    dependency = new SqlDependency(command, null, 5);
    // Subscribe to the SqlDependency event.
    dependency.OnChange += new OnChangeEventHandler(onDependencyChange);
    // start dependency listener
    SqlDependency.Start(connectionString);
    //ucmaSampleInstantMessagingCall.Run();
    private static void onDependencyChange(Object o, SqlNotificationEventArgs args)
    run();
    private void Run()
    // Initialize and startup the platform.
    Exception ex = null;
    try
    // Create the UserEndpoint
    _helper = new UCMASampleHelper();
    _userendpoint = _helper.CreateEstablishedUserEndpoint();
    Console.Write("The User Endpoint owned by URI: ");
    Console.Write(_userendpoint.OwnerUri);
    Console.WriteLine(" is now established and registered.");
    List<string> _Users = new List<string>();
    _Users.Add("sip:[email protected]");
    _Users.Add("sip:[email protected]");
    foreach (string useruri in _Users)
    // Setup the conversation and place the call.
    ConversationSettings convSettings = new ConversationSettings();
    convSettings.Priority = _conversationPriority;
    convSettings.Subject = _conversationSubject;
    // Conversation represents a collection of modes of communication
    // (media types)in the context of a dialog with one or multiple
    // callees.
    //Convers conver =new ConversationParticipant
    Conversation conversation = new Conversation(_userendpoint, convSettings);
    InstantMessagingCall _instantMessaging = new InstantMessagingCall(conversation);
    // Call: StateChanged: Only hooked up for logging. Generally,
    // this can be used to surface changes in Call state to the UI
    _instantMessaging.StateChanged += this.InstantMessagingCall_StateChanged;
    // Subscribe for the flow created event; the flow will be used to
    // send the media (here, IM).
    // Ultimately, as a part of the callback, the messages will be
    // sent/received.
    _instantMessaging.InstantMessagingFlowConfigurationRequested +=
    this.InstantMessagingCall_FlowConfigurationRequested;
    // Get the sip address of the far end user to communicate with.
    //String _calledParty = "sip:" +
    // UCMASampleHelper.PromptUser(
    // "Enter the URI of the user logged onto Microsoft Lync, in the User@Host format => ",
    // "RemoteUserURI");
    // Place the call to the remote party, without specifying any
    // custom options. Please note that the conversation subject
    // overrides the toast message, so if you want to see the toast
    // message, please set the conversation subject to null.
    // _instantMessaging.Conversation()
    _instantMessaging.BeginEstablish(useruri, new ToastMessage("Hello Toast"), null,
    CallEstablishCompleted, _instantMessaging);
    catch (InvalidOperationException iOpEx)
    // Invalid Operation Exception may be thrown if the data provided
    // to the BeginXXX methods was invalid/malformed.
    // TODO (Left to the reader): Write actual handling code here.
    ex = iOpEx;
    finally
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write actual handling code here.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    // Wait for sample to complete
    _sampleCompletedEvent.WaitOne();
    // Just to record the state transitions in the console.
    void InstantMessagingCall_StateChanged(object sender, CallStateChangedEventArgs e)
    Console.WriteLine("Call has changed state. The previous call state was: " + e.PreviousState +
    "and the current state is: " + e.State);
    // Flow created indicates that there is a flow present to begin media
    // operations with, and that it is no longer null.
    public void InstantMessagingCall_FlowConfigurationRequested(object sender,
    InstantMessagingFlowConfigurationRequestedEventArgs e)
    Console.WriteLine("Flow Created.");
    _instantMessagingFlow = e.Flow;
    // Now that the flow is non-null, bind the event handlers for State
    // Changed and Message Received. When the flow goes active,
    // (as indicated by the state changed event) the program will send
    // the IM in the event handler.
    _instantMessagingFlow.StateChanged += this.InstantMessagingFlow_StateChanged;
    // Message Received is the event used to indicate that a message has
    // been received from the far end.
    _instantMessagingFlow.MessageReceived += this.InstantMessagingFlow_MessageReceived;
    // Also, here is a good place to bind to the
    // InstantMessagingFlow.RemoteComposingStateChanged event to receive
    // typing notifications of the far end user.
    _instantMessagingFlow.RemoteComposingStateChanged +=
    this.InstantMessagingFlow_RemoteComposingStateChanged;
    private void InstantMessagingFlow_StateChanged(object sender, MediaFlowStateChangedEventArgs e)
    Console.WriteLine("Flow state changed from " + e.PreviousState + " to " + e.State);
    // When flow is active, media operations (here, sending an IM)
    // may begin.
    if (e.State == MediaFlowState.Active)
    // Send the message on the InstantMessagingFlow.
    _instantMessagingFlow.BeginSendInstantMessage(_messageToSend, SendMessageCompleted,
    _instantMessagingFlow);
    private void InstantMessagingFlow_RemoteComposingStateChanged(object sender,
    ComposingStateChangedEventArgs e)
    // Prints the typing notifications of the far end user.
    Console.WriteLine("Participant "
    + e.Participant.Uri.ToString()
    + " is "
    + e.ComposingState.ToString()
    private void InstantMessagingFlow_MessageReceived(object sender, InstantMessageReceivedEventArgs e)
    // On an incoming Instant Message, print the contents to the console.
    Console.WriteLine(e.Sender.Uri + " said: " + e.TextBody);
    // Shutdown if the far end tells us to.
    if (e.TextBody.Equals("bye", StringComparison.OrdinalIgnoreCase))
    // Shutting down the platform will terminate all attached objects.
    // If this was a production application, it would tear down the
    // Call/Conversation, rather than terminating the entire platform.
    _instantMessagingFlow.BeginSendInstantMessage("Shutting Down...", SendMessageCompleted,
    _instantMessagingFlow);
    _helper.ShutdownPlatform();
    _sampleCompletedEvent.Set();
    else
    // Echo the instant message back to the far end (the sender of
    // the instant message).
    // Change the composing state of the local end user while sending messages to the far end.
    // A delay is introduced purposely to demonstrate the typing notification displayed by the
    // far end client; otherwise the notification will not last long enough to notice.
    _instantMessagingFlow.LocalComposingState = ComposingState.Composing;
    Thread.Sleep(2000);
    //Echo the message with an "Echo" prefix.
    _instantMessagingFlow.BeginSendInstantMessage("Echo: " + e.TextBody, SendMessageCompleted,
    _instantMessagingFlow);
    private void CallEstablishCompleted(IAsyncResult result)
    InstantMessagingCall instantMessagingCall = result.AsyncState as InstantMessagingCall;
    Exception ex = null;
    try
    instantMessagingCall.EndEstablish(result);
    Console.WriteLine("The call is now in the established state.");
    catch (OperationFailureException opFailEx)
    // OperationFailureException: Indicates failure to connect the
    // call to the remote party.
    // TODO (Left to the reader): Write real error handling code.
    ex = opFailEx;
    catch (RealTimeException rte)
    // Other errors may cause other RealTimeExceptions to be thrown.
    // TODO (Left to the reader): Write real error handling code.
    ex = rte;
    finally
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write real error handling code.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    private void SendMessageCompleted(IAsyncResult result)
    InstantMessagingFlow instantMessagingFlow = result.AsyncState as InstantMessagingFlow;
    Exception ex = null;
    try
    instantMessagingFlow.EndSendInstantMessage(result);
    Console.WriteLine("The message has been sent.");
    catch (OperationTimeoutException opTimeEx)
    // OperationFailureException: Indicates failure to connect the
    // IM to the remote party due to timeout (called party failed to
    // respond within the expected time).
    // TODO (Left to the reader): Write real error handling code.
    ex = opTimeEx;
    catch (RealTimeException rte)
    // Other errors may cause other RealTimeExceptions to be thrown.
    // TODO (Left to the reader): Write real error handling code.
    ex = rte;
    finally
    // Reset the composing state of the local end user so that the typing notifcation as seen
    // by the far end client disappears.
    _instantMessagingFlow.LocalComposingState = ComposingState.Idle;
    if (ex != null)
    // If the action threw an exception, terminate the sample,
    // and print the exception to the console.
    // TODO (Left to the reader): Write real error handling code.
    Console.WriteLine(ex.ToString());
    Console.WriteLine("Shutting down platform due to error");
    _helper.ShutdownPlatform();
    #endregion
    So i want to call run method when new entry is added in the database . and this application is not like any asp.net form application . In form application we display data when programs loads as like your RefreshDataWithSqlDependency
    function . But in my application my application will run (send IM) when any new entry is added in the database . As I need running application to achieve notification , what kind of changes are required?

  • Dynamic Creation of list box on excel sheet and handling events

    hi all ,
    i m working on excel to sap integration application and for that i need to create dynmicaly list boxes in excel and also needs to handler events of each boxes..
    please suggest me somehting asap/
    thanks in advance,
    jigs
    helpful ans will be rewarded.

    hi all ,
    i m working on excel to sap integration application and for that i need to create dynmicaly list boxes in excel and also needs to handler events of each boxes..
    please suggest me somehting asap/
    thanks in advance,
    jigs
    helpful ans will be rewarded.

  • Handling events in ALV grid

    hi,
    Hi,
    I am displaying some fields from VBAP in ALV gid and have give drop down check box to storage location making it editable  so  if the user changes Storage location  of
    some entries and clicks SAVE button, when we click save button i need to capture all the rows that were been changed and update VA02 using these records through bapi.
    but iam not able to capture this SAVE event but iam able to capture Enter and cursor event.
    i have written following code for this
    LOCAL CLASSES: Definition
    class lcl_event_receiver: local class to handle event CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_data_changed
             FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    LOCAL CLASSES: Implementation
    class lcl_event_receiver (Implementation)
    CLASS lcl_event_receiver IMPLEMENTATION.
        METHOD handle_data_changed.
        DATA: l_error_in_data TYPE c.
        PERFORM handle_data_changed USING er_data_changed l_error_in_data.
    *§7.Display application log if an error has occured.
        IF l_error_in_data EQ 'X'.
          CALL METHOD er_data_changed->display_protocol.
        ENDIF.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    *&      Form  handle_data_changed
         Identify columns which were changed and check input
         -->P_ER_DATA_CHANGED  text
    FORM handle_data_changed  USING  p_er_data_changed
                              TYPE REF TO cl_alv_changed_data_protocol
                              p_error_in_data TYPE c.
      DATA : lw_mod_cell TYPE lvc_s_modi ,
             l_value TYPE lvc_value ,
             l_lgort TYPE lgort_d.
      SORT p_er_data_changed->mt_mod_cells BY row_id .
      LOOP AT p_er_data_changed->mt_mod_cells INTO lw_mod_cell
                              WHERE fieldname = 'LGORT'.
        CALL METHOD p_er_data_changed->get_cell_value
          EXPORTING
            i_row_id    = lw_mod_cell-row_id
            i_fieldname = 'LGORT'
          IMPORTING
            e_value     = l_value.
        SELECT SINGLE lgort FROM t001l INTO l_lgort WHERE werks = p_werks
                                                    AND   lgort = l_value.
        IF sy-subrc NE 0.
    In case of error, create a protocol entry in the *application log.
          CALL METHOD p_er_data_changed->add_protocol_entry
            EXPORTING
              i_msgid     = '0K'
              i_msgno     = '000'
              i_msgty     = 'E'
              i_msgv1     = text-003
              i_msgv2     = l_value
              i_msgv3     = text-004
              i_fieldname = lw_mod_cell-fieldname
              i_row_id    = lw_mod_cell-row_id.
          p_error_in_data  = 'X'.
          EXIT.
        ELSE.
    *§5b.If the value is valid change values of
       cells.
          CALL METHOD p_er_data_changed->modify_cell
            EXPORTING
              i_row_id    = lw_mod_cell-row_id
              i_fieldname = lw_mod_cell-fieldname
              i_value     = l_value.
          READ TABLE t_list1 INTO w_list1 INDEX lw_mod_cell-row_id.
          IF sy-subrc EQ 0.
    *comparing old value with the changed value
            IF w_list1-lgort <> l_value.
              MOVE:      w_list1-werks  TO w_list3-werks,
                         w_list1-matnr  TO w_list3-matnr,
                         w_list1-arktx  TO w_list3-arktx,
                         w_list1-vbeln  TO w_list3-vbeln,
                         w_list1-posnr  TO w_list3-posnr,
                         w_list1-pstyv  TO w_list3-pstyv,
                         w_list1-vstel  TO w_list3-vstel,
                         w_list1-auart  TO w_list3-auart,
                         w_list1-kwmeng TO w_list3-kwmeng,
                         w_list1-vrkme  TO w_list3-vrkme,
                         w_list1-mbdat  TO w_list3-mbdat,
                         l_value        TO w_list3-lgort.
              APPEND w_list3 TO t_list3.
    *t_list3 will contain all the records that are changed
              CLEAR w_list3.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDLOOP.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF go_custom_container IS INITIAL.
    create a custom container control for our ALV Control
        CREATE OBJECT go_custom_container
          EXPORTING
            container_name              = g_cont_on_main
                EXCEPTIONS
                    cntl_error = 1
                    cntl_system_error = 2
                    create_error = 3
                    lifetime_error = 4
                    lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc NE 0.
    Display error message.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = sy-repid
              txt2  = sy-subrc
              txt1  = 'The control could not be created'.
        ENDIF.
    create an instance of alv control
        CREATE OBJECT go_grid
          EXPORTING
            i_parent          = go_custom_container.
    *If display or change radio button is cheked
        IF ( p_chng = 'X' OR p_disp = 'X' ) .
    Set a titlebar for the grid control
          g_layout-grid_title = 'Sales Orders'.
          g_layout-excp_fname = 'TRAFFIC_LIGHT'.
    Define a drop down table.
          PERFORM set_drdn_table.
          CALL METHOD go_grid->set_table_for_first_display
            EXPORTING
              is_layout                     = g_layout
            CHANGING
              it_outtab                     = t_list1
              it_fieldcatalog               = t_fieldcat1
            EXCEPTIONS
              invalid_parameter_combination = 1
              program_error                 = 2
              too_many_lines                = 3
              OTHERS                        = 4.
          IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDIF.
    register ENTER and CURSOR to raise event DATA_CHANGED.
      (Per default the user may check data by using the check icon).
        CALL METHOD go_grid->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_enter.
        CALL METHOD go_grid->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
        CREATE OBJECT g_event_receiver.
        SET HANDLER g_event_receiver->handle_double_click  FOR go_grid.
        SET HANDLER g_event_receiver->handle_hotspot_click FOR  go_grid .
        SET HANDLER g_event_receiver->handle_data_changed  FOR  go_grid .
      ENDIF.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_grid.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      ok_code = sy-ucomm.
      CASE ok_code.
        WHEN 'EXIT'.
          PERFORM exit_program.
        WHEN 'SAVE'.
          PERFORM update_sales_order using t_list3[].
    endcase.
    Thanks in Advance,
    Siri

    Hi Sirisha,
              You can get the event code for Enter because you have regitered in the event reciever .
    But for the SAVE you will have to set in the PF-status of the screen and not the ALV-grid save .
    Please award if helpful.

  • Handling Events in FXML-includes

    Hi!
    I am using FXML to define the GUI of my application. As the GUI is pretty complex with many regions and items in it, I have created a separate FXML file for each main region to reduce the overall complexity of maintaining the design.
    My parent FXML file, called "Frame.xml", includes those "sub-regional" FXML-definitions using "<fx:include source="RegionXYZ.fxml" />".
    What I am now stucked with is, how to handle events in this approach...
    Questions:
    a) Can I add a separate controller in each of the "sub-regional" FXML-files, like "fx:controller="FXMLRegionXYZController"?
    b) Or must I, or even should I, use only a single controller inside the main FXML? Will this single controller be able to recognize and handle actions/events in the included FXML-definitions as well?
    c) What is the best approach in general for this?
    Thanks,
    Jörn

    Hi!
    I am using FXML to define the GUI of my application. As the GUI is pretty complex with many regions and items in it, I have created a separate FXML file for each main region to reduce the overall complexity of maintaining the design.
    My parent FXML file, called "Frame.xml", includes those "sub-regional" FXML-definitions using "<fx:include source="RegionXYZ.fxml" />".
    What I am now stucked with is, how to handle events in this approach...
    Questions:
    a) Can I add a separate controller in each of the "sub-regional" FXML-files, like "fx:controller="FXMLRegionXYZController"?
    - Yes, you can
    b) Or must I, or even should I, use only a single controller inside the main FXML? Will this single controller be able to recognize and handle actions/events in the included FXML-definitions as well?
    - if you could control everything from a single controller but you option (A) is much better
    c) What is the best approach in general for this?
    - Option (a)
    Thanks,
    Jörn

  • Javascript error in event handler event type = timeline

    Hi,
    I have a small EdgeAnimate projekt with version 1.5.0 and the local export works fine... I must include the package at a CMS and I update all paths to absolute paths and all files are loading...
    but I the animation dont play - I see at the javascript console the follow output
    javascript error in event handler event type = timeline   edge.1.5.0.min.js:143
    Springender Punkt: Rettungswagen - Der springende Punkt
    I dont found any solution... :-((

    Hi Scott,
    I have gone through your shared composition created in older verion of Edge.
    If you open the older composition html page in browser, there already have some of the error messages in the console as you mentioned above like
          Javascript error in event handler! Event Type = timeline.
    And as you said with the latest Edge, when you upgrade the old composition, some new error messages gets added to the existing ones.
    As in the latest Edge, the whole of runtime has been shake-up, some of the attributes has been removed and are added in different way.
    Example: To access timelines of a symbol:
         Old way:           sym.timelines['Default Timeline']
         New way:          sym.data[sym.name].timeline
    You need to make some modifications in index_edgeActions.js file like:
         1. Search & Replace "timelines['Default Timeline']" with "data[sym.name].timeline"
         2. And in the code taken from EdgeCommons.js, replace "getVariable("symbolSelector")" with "_variables["symbolSelector"]".
    Hope, these changes will remove the new JS issues you mentioned.
    hth,
    Vivekuma

  • How to handle events between two custom components?

    Hi ,
         i want to handle events between two custom components, example if an event is generated in one custom component ,and i want to handle it any where in the application.....can any one suggest me any tutorial or meterial in this concept...
    thanks

    Events don't really go sideways in ActionScript by default. They bubble upward. If you want to send an event sideways, you will probably have to coordinate with something higher up in the event hierarchy. You can send the event to a common ancestor, and then pass it down the hierarchy as a method argument.
    Another option is to use a framework that supports Injection. There are a number around these days. The one I'm most familiar with is Mate, which allows you to handle events and inject data in MXML. Mate is meant to be used as an MVC framework, and you may want to look into it if your application is complex, but you can also use it to coordinate global event handling if you don't need that level of structure.

  • Eventhandlers of children of application can not receive custom event dispatched by application

    Hello dear Adobe community,
    hope you can help me with this issue.
    When the application dispatches a custom event, the child uicomponent can only receive the event by using Application.application.addEventListener or systemManager.addEventListener. Simply adding a listener, without application or systemmanager, does not allow the event to be received by the child component.
    I want to be able to use the addEventListener and removeEventListener without SystemManager or Application.application, or could you provide a better workaround? How can I use the addEventListener, do I need to overwrite EventDispatcher, which I wouldnt like to do?
    Just to clarifiy, if i remove the systemManager in front of addEventListener(CustomEventOne.EventOne,sysManHandleCE,false) it will not add it and will not fire. 
    The code below is an example for this problem that the event is not getting fired in the right moment. The mainapplication got only a button with the customEventOne that gets dispatched.
    public
    class MyCanvas extends Canvas{
    public function MyCanvas()
    super();
    width=300;
    height=300;
    addEventListener(FlexEvent.CREATION_COMPLETE,handleCC,false,0,true);
    private function handleCC(event:FlexEvent):void
    removeEventListener(FlexEvent.CREATION_COMPLETE,handleCC);
    addEventListener(CustomEventOne.EventOne,handleCE,false,0,true);
    addEventListener(Event.REMOVED_FROM_STAGE,handleEvt,false,0,true);
    systemManager.addeventListener(CustomEventOne.eventOne,sysManHandleCE,false,0,true);
    private function handleEvt(event:Event):void
    trace("In removed from stage handler");
    systemManager.removeEventListener(CustomEventOne.EventOne,sysManHandleCE);
    trace(hasEventListener(FlexEvent.CREATION_COMPLETE));
    trace(hasEventListener(CustomEventOne.EventOne));
    trace(hasEventListener(Event.REMOVED_FROM_STAGE));
    private function handleCE(event:CustomEventOne):void
    trace("I got it");
    private function sysManHandleCE(event:CustomEventOne):void
    trace("I got it");
    public class CustomEventOne extends Event
    public static const EventOne:String = "EventOne";
    public function CustomEventOne(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
    super(type, bubbles, cancelable);
    override public functionclone():Event
    return newCustomEventOne(type,bubbles,cancelable);
    Thank you in advance,
    Michael

    I think you need to look at event propogation. The object that dispatches an event will be sitting on the display tree. The event propagates up the tree to the roots. Your canvas should be attached to the application, but even then it sits lower in the tree branches than the event dispatcher, so it won't see the event being dispatched because the event is not propagated to the children of the object that dispatches it but to the parent of the object that dispatches it.
    So, your canvas is a child of the application, but dispatching the event from the application means that the canvas doesn't see it because events are notified up the tree using the parent link, not the child links.
    You may wish to investigate how the display list and event propagation works and then the MVC pattern.
    Paul

  • Capturing keystroke event in console-mode

    Hi fellow Java Programmer
    I was stumbled upon what to be a simple question
    Is it possible to capture the keystroke event inside console-based application
    This is my scenario:
    I have a thread that is keep running for a predetermined amount of time,
    It is doing a background-sort-of-task. According to the requirement, it must be able to detect
    when the user press 'R' (which will trigger Reload) or when user press 'Q' (denoting Quit)
    I would appreciate if somebody come up with hint / snippet of source code
    regards,
    Honggo

    try something like this...
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s;
    s = br.readLine();
    if(s.equals("R")){
    if(s.equals("R")){
    you also can use s.equalsIgnoreCase("R") if u dont care if its capital or not

  • Question re-posted: Way to get events from outside application

    Hello,
    FatCo asked this question but has not got a reply. I have the same question, so I re-post it, hoping someone could give us help. How can we write JNI code to do it on a Windows OS? Assume appliction 2 is a Internet Explorer.
    Thank you!
    --Bin
    Author: FaTCo Sep 24, 2002 1:17 PM
    Hello,
    is there a way to get events from other applications, either native or java applications?
    For example application 1 (Java or not) is getting minimized, is there a way to notice application 2 (Java) about that?

    I am not really a Windows programmer so I cannot say how you can get the event notification in C(++) but if you can get it there then there should be no particular problem communicating that information to Java.
    This might take the form of creating a thread (all threads are native threads on Windows) which blocks on receiving this event and then notifies the rest of the application somehow, maybe by setting a global flag, using Object.notify() to wake up some other thread to do the processing, or simply by calling a Java method to do all the necessary handling before returning. But there is nothing special about this part.
    It all depends on how you can receive the event notification in C++.

  • Calling Console Application that uses WebBrowser from SQL Server - Not Running

    Hi there. I am working in a program automation that needs to get files from a website and put it in a database. It is done but as I need a console application and need webbrowser that comes from Windows Forms, I am trying to call it from the SQL Server using
    the xp_cmdshell but when it runs the .exe, it execute the block that is before the Application.Run() command but when it reaches this line, it stay running on Task manager but it not execute my code. How can I fix this? I had first created a Windows form application
    but it was not working anyway and then I tried a console application and then I use the [STAThread] and Application.Run(). At least it runs the file from SQL Server but is not executing all my code, I think that it stops on Application.Run() line. Any help
    will be very useful.
    Thanks for now.

    Thanks for the response. What I mean is that it just run the part of the code that is just using the Console, that's the code:
    // Main Method
    [STAThread]
    public static void Main()
    clearDatabase(myConnection);
    Console.Title = "Suframa Itens Robot";
    //If log file exists, it is deleted
    if ( File.Exists(@"suframaLog.txt") )
    File.Delete(@"suframaLog.txt");
    wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(loginWebsite);
    try
    //It is called as the program uses the WebBrowser Class from Windows Forms namespace
    //and it is a console Application
    Application.Run();
    catch ( Exception ex )
    Log(ex.Message);
    As you can see, I call a function on start named ClearDatabase, when I call the file from sql server it executes, the tables are cleared, but what I think is that the problem stop when reach the line Application.Run() as it is the line that allows the remaining
    code to execute as it uses events from WebBrowser class. 
    It is a program automation that needs to get a lot of files from a website that needs login and read line by line from the files and put on server, if I call it from the executable it runs fine, the only problem is when calling from SQL Server, Do you know
    how to fix this?
    Thanks.

Maybe you are looking for

  • Error while migrating a single agreement on B2B

    Hi Gurus, When i migrate a single Trading Partner configuration(agreement) from Dev B2B Server to PROD B2B Server and after that validate the agreements then it gives me the following error- Error Agreement Kroger 875 Inbound is invalid. AIP-16222: T

  • Moving users from One Group to another

    Hi Guys, I am looking for a script which will allow me to move users from One ADGroup to another ADGroup. I have checked ther scripts which are currently present. However, none of them if fixing my issue. Details: I have Different locations and users

  • Table controls in LSMW

    Hi friends, Iam doing the LSMW for Source list(ME01) for  Materail.. Its a small transaction..Number fields also less compare to other transaction.. Problem is..its completely table control.. how can i give the fields in file format..   How its commi

  • How to install .SAR file

    I just downloaded Netweaver Developer Studio SP 11. Its in .SAR format. Am wondering how to install it?

  • Standard deviation in abap

    Dear Freinds, I want to calculate standard deviation of my internal table columns  in abap code , please help me how to calculate it  . Thanks, Naveen