Event handling - output doubled?!

hi, i'm trying to implement some event handling through an extension of the MouseAdapter class, but the output comes out twice for some reason. code is as follows:
note: for some reason an 'i' enclosed in square brackets isn't shown in these forums, but makes things italic... any idea how to change that?!
public void mouseClicked(MouseEvent e)
p = e.getPoint() ;
for(int i = 0 ; i < myproj.length ; i++)
rect = myproj.getDshape() ;
System.out.println(rect.toString()) ;
if (rect.contains(p))
System.out.println(i) ;
System.out.println(myproj.length) ;
System.out.println("clicked one!") ;
System.out.println(p.toString()) ;
System.out.println(myproj[i].getDname() + " : " + myproj[i].getStrength() + " : " + myproj[i].getDom()) ;
wanted++ ;
System.out.println("Count: " + counter) ;
counter++ ;
} // end class MyEventHandler
however, when i click in one of the 2 rectangles on my applet, the following output is printed:
java.awt.Rectangle[x=521,y=50,width=25,height=25]
0
2
clicked one!
java.awt.Point[x=541,y=62]
tom : 4.51 : 1
Count: 0
java.awt.Rectangle[x=571,y=80,width=25,height=25]
java.awt.Rectangle[x=521,y=50,width=25,height=25]
0
2
clicked one!
java.awt.Point[x=541,y=62]
tom : 4.51 : 1
Count: 1
java.awt.Rectangle[x=571,y=80,width=25,height=25]
anyone got any ideas why it does this twice? i have also tried this with mousepressed and mousereleased as well as mouseclicked, but the same occurs...

You're probably adding the mouseListener to your component twice, but you don't show that part of the code so it's hard to tell for sure.
'i' enclosed in square brackets isn't shown in these forums, but makes things italicClick on the help link at the top of the page. It explains some formatting codes you can use to make your code easier to read.
... - italic
... - highlights java keywords and comments

Similar Messages

  • Swing: when trying to get the values from a JTable inside an event handler

    Hi,
    I am trying to write a graphical interface to compute the Gauss Elimination procedure for solving linear systems. The class for computing the output of a linear system already works fine on console mode, but I am fighting a little bit to make it work with Swing.
    I put two buttons (plus labels) and a JTextField . The buttons have the following role:
    One of them gets the value from the JTextField and it will be used to the system dimension. The other should compute the solution. I also added a JTable so that the user can type the values in the screen.
    So whenever the user hits the button Dimensiona the program should retrieve the values from the table cells and pass them to a 2D Array. However, the program throws a NullPointerException when I try to
    do it. I have put the code for copying this Matrix inside a method and I call it from the inner class event handler.
    I would thank you very much for the help.
    Daniel V. Gomes
    here goes the code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import AdvanceMath.*;
    public class MathF2 extends JFrame {
    private JTextField ArrayOfFields[];
    private JTextField DimOfSis;
    private JButton Calcular;
    private JButton Ativar;
    private JLabel label1;
    private JLabel label2;
    private Container container;
    private int value;
    private JTable DataTable;
    private double[][] A;
    private double[] B;
    private boolean dimensionado = false;
    private boolean podecalc = false;
    public MathF2 (){
    super("Math Calcs");
    Container container = getContentPane();
    container.setLayout( new FlowLayout(FlowLayout.CENTER) );
    Calcular = new JButton("Resolver");
    Calcular.setEnabled(false);
    Ativar = new JButton("Dimensionar");
    label1 = new JLabel("Clique no bot�o para resolver o sistema.");
    label2 = new JLabel("Qual a ordem do sistema?");
    DimOfSis = new JTextField(4);
    DimOfSis.setText("0");
    JTable DataTable = new JTable(10,10);
    container.add(label2);
    container.add(DimOfSis);
    container.add(Ativar);
    container.add(label1);
    container.add(Calcular);
    container.add(DataTable);
    for ( int i = 0; i < 10 ; i ++ ){
    for ( int j = 0 ; j < 10 ; j++) {
    DataTable.setValueAt("0",i,j);
    myHandler handler = new myHandler();
    Calcular.addActionListener(handler);
    Ativar.addActionListener(handler);
    setSize( 500 , 500 );
    setVisible( true );
    public static void main ( String args[] ){
    MathF2 application = new MathF2();
    application.addWindowListener(
    new WindowAdapter(){
    public void windowClosing (WindowEvent event)
    System.exit( 0 );
    private class myHandler implements ActionListener {
    public void actionPerformed ( ActionEvent event ){
    if ( event.getSource()== Calcular ) {
    if ( event.getSource()== Ativar ) {
    //dimensiona a Matriz A
    if (dimensionado == false) {
    if (DimOfSis.getText()=="0") {
    value = 2;
    } else {
    value = Integer.parseInt(DimOfSis.getText());
    dimensionado = true;
    Ativar.setEnabled(false);
    System.out.println(value);
    } else {
    Ativar.setEnabled(false);
    Calcular.setEnabled(true);
    podecalc = true;
    try {
    InitValores( DataTable, value );
    } catch (Exception e) {
    System.out.println("Erro ao criar matriz" + e );
    private class myHandler2 implements ItemListener {
    public void itemStateChanged( ItemEvent event ){
    private void InitValores( JTable table, int n ) {
    A = new double[n][n];
    B = new double[n];
    javax.swing.table.TableModel model = table.getModel();
    for ( int i = 0 ; i < n ; i++ ){
    for (int j = 0 ; j < n ; j++ ){
    Object temp1 = model.getValueAt(i,j);
    String temp2 = String.valueOf(temp1);
    A[i][j] = Double.parseDouble(temp2);

    What I did is set up a :
    // This code will setup a listener for the table to handle a selection
    players.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    ListSelectionModel rowSM = players.getSelectionModel();
    rowSM.addListSelectionListener(new Delete_Player_row_Selection(this));
    //Class will take the event and call a method inside the Delete_Player object.
    class Delete_Player_row_Selection
    implements javax.swing.event.ListSelectionListener
    Delete_Player adaptee;
    Delete_Player_row_Selection (Delete_Player temp)
    adaptee = temp;
    public void valueChanged (ListSelectionEvent listSelectionEvent)
    adaptee.row_Selection(listSelectionEvent);
    in the row_Selection function
    if(ex.getValueIsAdjusting()) //To remove double selection
    return;
    ListSelectionModel lsm = (ListSelectionModel) ex.getSource();
    if(lsm.isSelectionEmpty())
    System.out.println("EMtpy");
    else
    int selected_row = lsm.getMinSelectionIndex();
    ResultSetTableModel model = (ResultSetTableModel) players.getModel();
    String name = (String) model.getValueAt(selected_row, 1);
    Integer id = (Integer) model.getValueAt(selected_row, 3);
    This is how I got info out of a table when the user selected it

  • Event handling in global class (abap object)

    Hello friends
    I have 1 problem regarding events in abap object... how to handel an event in global class in se24 .
    Regards
    Reema jain.
    Message was edited by:
            Reema Jain

    Hello Reema
    The following sample report shows how to handle event in principle (see the § marks)..
    The following sample report show customer data ("Header"; KNB1) in the first ALV list and sales areas ("Detail"; KNVV) for the selected customer (event double-click) in the second ALV list.
    *& Report  ZUS_SDN_TWO_ALV_GRIDS
    REPORT  zus_sdn_two_alv_grids.
    DATA:
      gd_okcode        TYPE ui_func,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_cell_top      TYPE REF TO cl_gui_container,
      go_cell_bottom   TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      gs_layout        TYPE lvc_s_layo.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1,
      gt_knvv          TYPE STANDARD TABLE OF knvv.
    "§1. Define and implement event handler method
    "     (Here: implemented as static methods of a local class)
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
    *   define local data
        DATA:
          ls_knb1      TYPE knb1.
        CHECK ( sender = go_grid1 ).
        READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        CALL METHOD go_grid1->set_current_cell_via_id
          EXPORTING
    *        IS_ROW_ID    =
    *        IS_COLUMN_ID =
            is_row_no    = es_row_no.
    *   Triggers PAI of the dynpro with the specified ok-code
        CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = '1000'.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 2
          columns           = 1
    *      NO_AUTODEF_PROGID_DYNNR =
    *      NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_top.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 2
          column    = 1
        RECEIVING
          container = go_cell_bottom.
    * Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_cell_top
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    "§2. Set event handler (after creating the ALV instance)
      SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.  " Or:
    " SET HANDLER: lcl_eventhandler=>handle_double_click FOR all instances.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent          = go_cell_bottom
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Display data
      gs_layout-grid_title = 'Customers'.
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNB1'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = gt_knb1
        EXCEPTIONS
          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.
      gs_layout-grid_title = 'Customers Details (Sales Areas)'.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNVV'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = gt_knvv  " empty !!!
        EXCEPTIONS
          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.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          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.
    * NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    * Flow logic of dynpro (does not contain any dynpro elements):
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    *  SET TITLEBAR 'xxx'.
    * Refresh display of detail ALV list
      CALL METHOD go_grid2->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          OTHERS         = 2.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
    *   User has pushed button "Display Details"
        WHEN 'DETAIL'.
          PERFORM entry_show_details.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  ENTRY_SHOW_DETAILS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM entry_show_details .
    * define local data
      DATA:
        ld_row      TYPE i,
        ls_knb1     TYPE knb1.
      CALL METHOD go_grid1->get_current_cell
        IMPORTING
          e_row = ld_row.
      READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
      CHECK ( syst-subrc = 0 ).
      SELECT        * FROM  knvv INTO TABLE gt_knvv
             WHERE  kunnr  = ls_knb1-kunnr.
    ENDFORM.                    " ENTRY_SHOW_DETAILS
    Regards
    Uwe

  • Event handling in oops alv

    hi experts,
    event double click.
    when double click  on vbeln it should go to va03 transaction . how would i do that in oops alv.

    hai,
    you can go through code below .
    *& Report  Z_CLARIFY                                                   *
    REPORT  Z_CLARIFY                               .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: IT_ROW_NO TYPE LVC_T_ROID,
          X_ROW_NO TYPE LVC_S_ROID.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         CELLCOLOR TYPE LVC_T_SCOL, "required for color
         DROP(10),
         END OF ITAB.
    *The Below Definitions Must.....
    DATA:
    Reference to document
           DG_DYNDOC_ID       TYPE REF TO CL_DD_DOCUMENT,
    Reference to split container
           DG_SPLITTER          TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
    Reference to grid container
           DG_PARENT_GRID     TYPE REF TO CL_GUI_CONTAINER,
    Reference to html container
           DG_HTML_CNTRL        TYPE REF TO CL_GUI_HTML_VIEWER,
    Reference to html container
           DG_PARENT_HTML     TYPE REF TO CL_GUI_CONTAINER.
    "up to here
          CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO,
        TOP_OF_PAGE FOR EVENT TOP_OF_PAGE              "event handler
                             OF CL_GUI_ALV_GRID
                             IMPORTING E_DYNDOC_ID.
           END_OF_LIST FOR EVENT end_of_list              "event handler
                            OF CL_GUI_ALV_GRID
                            IMPORTING E_DYNDOC_ID.
    ENDCLASS.                    "lcl_event_handler DEFINITION
          CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
       MESSAGE I000 WITH V_ROW 'clicked'.
        CLEAR IT_ROW_NO[].
        X_ROW_NO-ROW_ID = V_ROW.
        APPEND X_ROW_NO TO IT_ROW_NO .
        CALL METHOD G_GRID->SET_SELECTED_ROWS
          EXPORTING
            IT_ROW_NO = IT_ROW_NO.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW.
        V_COLUMN = E_COLUMN.
        V_ROW_NUM = ES_ROW_NO.
        IF E_COLUMN = 'VBELN'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
        ENDIF.
        IF E_COLUMN = 'POSNR'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."
        ENDIF.
      ENDMETHOD.                    "handle_double_click
    METHOD END_OF_LIST.                   "implementation
    Top-of-page event
       PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
    ENDMETHOD.                            "top_of_page
        METHOD TOP_OF_PAGE.                   "implementation
    Top-of-page event
        PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
      ENDMETHOD.                            "top_of_page
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
    "Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    data: v_lines type i.
    data: v_line(3) type c.
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
                   START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    describe table itab lines v_lines.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
       MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
          text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      "attention.....from here
      "split your container here...into two parts
      "create the container
      CREATE OBJECT G_CUSTOM_CONTAINER
               EXPORTING CONTAINER_NAME = 'SCR100_CUST'.
      "this is for top of page
    Create TOP-Document
      CREATE OBJECT DG_DYNDOC_ID
                       EXPORTING STYLE = 'ALV_GRID'.
    Create Splitter for custom_container
      CREATE OBJECT DG_SPLITTER
                 EXPORTING PARENT  = G_CUSTOM_CONTAINER
                           ROWS    = 2
                           COLUMNS = 1.
    Split the custom_container to two containers and move the reference
    to receiving containers g_parent_html and g_parent_grid
      "i am allocating the space for grid and top of page
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 1
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_HTML.
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 2
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_GRID.
    CALL METHOD DG_SPLITTER->GET_CONTAINER
       EXPORTING
         ROW       = 2
         COLUMN    = 1
       RECEIVING
         CONTAINER = DG_PARENT_HTML.
    CALL METHOD DG_SPLITTER->GET_CONTAINER
       EXPORTING
         ROW       = 1
         COLUMN    = 1
       RECEIVING
         CONTAINER = DG_PARENT_GRID.
      "you can set the height of it
    Set height for g_parent_html
      CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT
        EXPORTING
          ID     = 1
          HEIGHT = 5.
      "from here as usual..you need to specify parent as splitter part
      "which we alloted for grid
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = DG_PARENT_GRID.
    Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.
      SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    Build fieldcat and set editable for date and reason code
    edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    Optionally restrict generic functions to 'change only'.
      (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
      "do these..{
    Initializing document
      CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.
    Processing events
      CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'TOP_OF_PAGE'
          I_DYNDOC_ID  = DG_DYNDOC_ID.
      "end }
    Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
          text
         -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    Only allow to change data not to create new entries (exclude
    generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
          Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    there are many such examples
    goto->se38->type bcalv* and press f4, u can see many examples.
    Reward points if helpful.
    Thanks and regards
    Swetha Singh.

  • Event handling in applets

    Hi,
    I have a simple applet of a sound calculator. I have two events - one for capturing data from the buttons pressed on the applet and the other to output the sound associated with the button. However only one method is working ie: the sound! If I put the the sound method in comments however the other method works. Can somebody help me pls?
    import java.awt.*;
    import java.lang.*;
    import java.applet.Applet;
    //===================
    // Calculator Applet
    //===================
    public class Calc extends Applet
    // member
    TextField text;
    String sText1, sText2;
    double dReg1, dReg2, dMem;
    String sOperator;
    boolean isFixReg;
    Object arg;
    Button plus, minus, division, times, SQRT, changesign, getmemory, memorycancelled, memorysave, equals;
    Button numbers[], extras[];
    // constructor
    public Calc()
    Panel pFrame = new Panel();
    pFrame.setLayout(new FlowLayout());
    text = new TextField("");
    text.setForeground(Color.black);
    text.setEditable(false);
    Panel pCalc = new Panel();
    pCalc.setLayout(new BorderLayout(0, 10));
    pCalc.add("North", text);
    pFrame.add("Center", pCalc);
    Dimension dSize= pCalc.size();
    dSize.width = dSize.width + 20;
    dSize.height = dSize.height + 20;
    pFrame.resize(dSize);
    Panel pKey = new Panel();
    pKey.setLayout(new GridLayout(6, 3, 3, 3));
    add("Center", pKey);
    numbers = new Button [10];
              extras = new Button [2];
    pKey.add(extras[0] = new Button("C"));
    pKey.add(getmemory = new Button("MR"));
    pKey.add(memorycancelled = new Button("M-"));
    pKey.add(memorysave = new Button("M+"));
    pKey.add(numbers[7] = new Button("7"));
    pKey.add(numbers[8] = new Button("8"));
    pKey.add(numbers[9] = new Button("9"));
    pKey.add(division = new Button("/"));
    pKey.add(numbers[4] = new Button("4"));
    pKey.add(numbers[5] = new Button("5"));
    pKey.add(numbers[6] = new Button("6"));
    pKey.add(times = new Button("*"));
    pKey.add(numbers[1] = new Button("1"));
    pKey.add(numbers[2] = new Button("2"));
    pKey.add(numbers[3] = new Button("3"));
    pKey.add(minus = new Button("-"));
    pKey.add(numbers[0] = new Button("0"));
    pKey.add(extras[1] = new Button("."));
    pKey.add(equals = new Button("="));
    pKey.add(plus = new Button("+"));
    pKey.add(SQRT = new Button("SQRT"));
    pKey.add(changesign = new Button("+/-"));
    pCalc.add("South", pKey);
    setLayout(new BorderLayout(0, 0));
    add("North", pFrame);
    setBackground(Color.darkGray);
    dReg1 = 0.0d;
    dReg2 = 0.0d;
    dMem = 0.0d;
    sOperator = "";
    text.setText("0");
    isFixReg = true;
    // event handler
    public boolean action(Event event, Object arg)
    // numeric key input
    if ("C".equals(arg))
    dReg1 = 0.0d;
    dReg2 = 0.0d;
    sOperator = "";
    text.setText("0");
    isFixReg = true;
    else if (("0".equals(arg)) | ("1".equals(arg)) | ("2".equals(arg))
    | ("3".equals(arg)) | ("4".equals(arg)) | ("5".equals(arg))
    | ("6".equals(arg)) | ("7".equals(arg)) | ("8".equals(arg))
    | ("9".equals(arg)) | (".".equals(arg)))
    if (isFixReg)
    sText2 = (String) arg;
    else
    sText2 = text.getText() + arg;
    text.setText(sText2);
    isFixReg = false;
    // operations
    else if (("+".equals(arg)) | ("-".equals(arg)) | ("*".equals(arg)) |
    ("*".equals(arg)) | ("SQRT".equals(arg)) |("+/-".equals(arg))|("=".equals(arg)))
    sText1 = text.getText();
    dReg2 = (Double.valueOf(sText1)).doubleValue();
    dReg1 = Calculation(sOperator, dReg1, dReg2);
    Double dTemp = new Double(dReg1);
    sText2 = dTemp.toString();
    text.setText(sText2);
    sOperator = (String) arg;
    isFixReg = true;
    // memory read operation
    else if ("memorysave".equals(arg))
    Double dTemp = new Double(dMem);
    sText2 = dTemp.toString();
    text.setText(sText2);
    sOperator = "";
    isFixReg = true;
    // memory add operation
    else if ("getmemory".equals(arg))
    sText1 = text.getText();
    dReg2 = (Double.valueOf(sText1)).doubleValue();
    dReg1 = Calculation(sOperator, dReg1, dReg2);
    Double dTemp = new Double(dReg1);
    sText2 = dTemp.toString();
    text.setText(sText2);
    dMem = dMem + dReg1;
    sOperator = "";
    isFixReg = true;
    // memory sub operation
    else if ("memorycancelled".equals(arg))
    sText1 = text.getText();
    dReg2 = (Double.valueOf(sText1)).doubleValue();
    dReg1 = Calculation(sOperator, dReg1, dReg2);
    Double dTemp = new Double(dReg1);
    sText2 = dTemp.toString();
    text.setText(sText2);
    dMem = dMem - dReg1;
    sOperator = "";
    isFixReg = true;
    return true;
    public boolean handleEvent( Event event ) {
         if ( event.target == plus ) {
         play( getCodeBase(), "plus.au" );
         return true;
         if ( event.target == minus ) {
         play( getCodeBase(), "minus.au" );
         return true;
         if ( event.target == times ) {
         play( getCodeBase(), "times.au" );
         return true;
         if ( event.target == division ) {
         play( getCodeBase(), "division.au" );
         return true;
         if ( event.target == SQRT ) {
         play( getCodeBase(), "SQRT.au" );
         return true;
         if ( event.target == changesign ) {
         play( getCodeBase(), "changesign.au" );
         return true;
         if ( event.target == getmemory ) {
         play( getCodeBase(), "getmemory.au" );
         return true;
         if ( event.target == memorycancelled ) {
         play( getCodeBase(), "memorycancelled.au" );
         return true;
         if ( event.target == memorysave ) {
         play( getCodeBase(), "memorysave.au" );
         return true;
         if ( event.target == equals ) {
         play( getCodeBase(), "equals.au" );
         return true;
              for (int count = 0; count < numbers.length; count++){
                   if ( event.target == numbers[count] ) {
         play( getCodeBase(), "ding.au" );
         return true;
              for (int count = 0; count < extras.length; count++){
                   if ( event.target == extras[count] ) {
         play( getCodeBase(), "dong.au" );
         return true;
              return super.handleEvent( event );
    // Calculation
    private double Calculation(String sOperator, double dReg1, double dReg2)
    if ("+".equals(sOperator)) dReg1 = dReg1 + dReg2;
    else if ("-".equals(sOperator)) dReg1 = dReg1 - dReg2;
    else if ("*".equals(sOperator)) dReg1 = dReg1 * dReg2;
    else if ("/".equals(sOperator)) dReg1 = dReg1 / dReg2;
    else if ("SQRT".equals(sOperator)) dReg1 = Math.sqrt (dReg1);
    else if ("+/-".equals(sOperator)) dReg1 = -dReg1;
    else dReg1 = dReg2;
    return dReg1;
    }

    I take it you are talking about action and handleEvent, I don't see action called any place--I put it in the "find on this page" search and your declaration is the only place it is found, so could you post one where you actually make calls appropirately for each method (how you want them implemented) and use code tags?
    My old eyes, as well as others' on here, just don't pick that needle out of the haystack like they did when we were 20 years old.

  • Dynpro: event handling on input field in custom control?

    Hello,
    can I  put an input/output Field in Custom Control?
    I have seen this (DD_ADD_FORM_INPUT) but i dont need a Form.
    What i want to do is: Double Click Event handling on the input field in the custom control.
    Thank you?

    Hi Mohi,
    OK, you could reduce DD_ADD_FORM_INPUT to what you really need - but the DD elements (rarely if ever used in standard SAP) do not have a double-click event. Must stick to ENTER.
    An alternative is a text_edit or an editable grid_control with one line one field.
    The problem is: There is no way to put any selection-screen element on a control.
    I's go for the grid approach as you certainly may have some more fields of interest.
    Regards,
    Clemens.

  • About CL_GUI_ALV_GRID's event-handling & PAI/PBO

    Hi, all,
    I met a problem when using CL_GUI_ALV_GRID's event-handling.
    I created a simple event-handling-class with an event-handling-method for DOUBLE-CLICK event of CL_GUI_ALV_GRID. And the event-handling-method, only makes some changes to the contents of itab to be shown in ALV_GRID.
    The problem is: In my idea, after event-dispatch and event-handling in PAI, subsequent PBO will be called. Since SET_TABLE_FOR_FIRST_DISPLAY is called in PBO, I would saw the changed itab shown. BUT, I saw the contents of the itab remaining unchanged.
    * PAI module, DISPATCH the event
      CASE OK_CODE.
        WHEN OTHERS.
          CALL METHOD cl_gui_cfw=>dispatch.
      ENDCASE.
    I debugged, and found that, after event-handling-method, PBO module doesn't execute.
    That's my wondering, after the preceding PAI, shouldn't the subsequent PBO appear? OR is event-handling different from other user actions?
    Many thanks.

    Hi,
    for double click you need explicit handler ,
    just check it.
    REPORT  ZTEST1234    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID,  "First
          G_GRID1 TYPE REF TO CL_GUI_ALV_GRID. "Second
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST', "First Container
          G_CONTAINER2 TYPE SCRFNAME VALUE 'TEST1',"Second container
          GS_LAYOUT TYPE LVC_S_LAYO.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         LFDAT like lips-vfdat,
         BOX(1),
         HANDLE_STYLE TYPE LVC_T_STYL,
         END OF ITAB.
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Handler to Check the Data Change
        HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
                             OF CL_GUI_ALV_GRID
                             IMPORTING ER_DATA_CHANGED
                                       E_ONF4
                                       E_ONF4_BEFORE
                                       E_ONF4_AFTER,
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
        MESSAGE I000 WITH V_ROW 'clicked'.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW.
        V_COLUMN = E_COLUMN.
        V_ROW_NUM = ES_ROW_NO.
        IF E_COLUMN = 'VBELN'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
        ENDIF.
        IF E_COLUMN = 'POSNR'.
          MESSAGE I000 WITH 'Click on POSNR row number '  E_ROW.
          "with this row num you can get the data
        ENDIF.
      ENDMETHOD.                    "handle_double_click
    **Handle Data Change
      METHOD HANDLE_DATA_CHANGED.
        CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
          EXCEPTIONS
            FINISHED = 1
            OTHERS   = 2.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDMETHOD.                    "HANDLE_DATA_CHANGED
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER, "handler
                G_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER. "Container2
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
    "First Grid
      CREATE OBJECT G_CUSTOM_CONTAINER
             EXPORTING CONTAINER_NAME = G_CONTAINER1.
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    "Second Grid
      CREATE OBJECT G_CUSTOM_CONTAINER1
             EXPORTING CONTAINER_NAME = G_CONTAINER2.
      CREATE OBJECT G_GRID1
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER1.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-BOX_FNAME = 'BOX'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
      GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
    *  SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.
    data: ls_outatb like line of itab,
          v_index type sy-tabix.
    DATA: LS_EDIT TYPE LVC_S_STYL,
            LT_EDIT TYPE LVC_T_STYL.
    LOOP AT ITAB INTO ls_outatb WHERE POSNR = '000010'.
        V_INDEX = SY-TABIX.
        LS_EDIT-FIELDNAME = 'VBELN'.
        LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
        LS_EDIT-STYLE2 = SPACE.
        LS_EDIT-STYLE3 = SPACE.
        LS_EDIT-STYLE4 = SPACE.
        LS_EDIT-MAXLEN = 8.
        INSERT LS_EDIT INTO TABLE LT_EDIT.
        INSERT LINES OF LT_EDIT INTO TABLE ls_outatb-handle_style.
        MODIFY ITAB INDEX V_INDEX FROM ls_outatb  TRANSPORTING
                                          HANDLE_STYLE.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
    **Calling the Method for ALV output for First Grid
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
    **Calling the Method for ALV output for Second Grid
       CALL METHOD G_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
    *    EXPORTING
    *      IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-EDIT      = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
        L_POS = L_POS + 1.
        X_FIELDCAT-SCRTEXT_M = 'Del Date'(015).
      X_FIELDCAT-FIELDNAME = 'LFDAT'.
      X_FIELDCAT-TABNAME = 'ITAB'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '10'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    Regards
    vijay

  • How can I execute an external program from within a button's event handler?

    I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
    I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
    I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
    I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
    So, then, how can I do this?
    Thanks
    Ted
    NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
    NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
            try {
                java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
                //pn.directory(new java.io.File("K:\\work"));
                java.lang.Process pr = pn.start();
                java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
                String tmp = new String("");
                byte b[] = new byte[1000];
                int i = 0;
                while (i != -1) {
                    bis.read(b);
                    tmp += new String(b);
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
            } catch (java.io.IOException ex) {
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
            }

    Hi Fonsi!
    One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
    /Thomas

  • WPF UI running in seperate runspace - able to set/get controls via synchronized hash table, but referencing the control via the hash table from within an event handler causes both runspaces to hang.

    I am trying to build a proof of concept where a WPF form is hosted in a seperate runspace and updates are handled from the primary shell/runspace. I have had some success thanks to a great article by Boe Prox, but I am having an issue I wanted to open up
    to see if anyone had a suggestion.
    My goals are as follows:
    1.) Set control properties from the primary runspace (Completed)
    2.) Get control properties from the primary runspace (Completed)
    3.) Respond to WPF form events in the UI runspace from the primary runspace (Kind of broken).
    I have the ability to read/write values to the form, but I am having difficulty with events. Specifically, I can fire and handle events, but the minute I try to reference the $SyncHash from within the event it appears to cause a blocking condition hanging both
    runspaces. As a result, I am unable to update the form based on an event being fired by a control.
    In the example below, the form is loaded and the following steps occur:
    1.) Update-Combobox is called and it populates the combobox with a list of service names and selects the first item.
    2.) update-textbox is called and sets the Text property of the textbox.
    3.) The Text value of the textbox is read by the function read-textbox and output using write-host.
    4.) An event handle is registered for the SelectionChanged event for the combobox to call the update-textbox function used earlier.
    5.) If you change the selection on the combobox, the shell and UI hangs as soon as $SyncHash is referenced. I suspect this is causing some sort of blocking condition from multiple threads trying to access the synchronized nature of the hash table, but I am
    unsure as to why / how to work around it. If you comment out the line "$SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})" within update-textbox the event handler will execute/complete.
    $UI_JobScript =
    try{
    Function New-Form ([XML]$XAML_Form){
    $XML_Node_Reader=(New-Object System.Xml.XmlNodeReader $XAML_Form)
    [Windows.Markup.XamlReader]::Load($XML_Node_Reader)
    try{
    Add-Type –AssemblyName PresentationFramework
    Add-Type –AssemblyName PresentationCore
    Add-Type –AssemblyName WindowsBase
    catch{
    Throw "Unable to load the requisite Windows Presentation Foundation assemblies. Please verify that the .NET Framework 3.5 Service Pack 1 or later is installed on this system."
    $Form = New-Form -XAML_Form $SyncHash.XAML_Form
    $SyncHash.Form = $Form
    $SyncHash.CMB_Services = $SyncHash.Form.FindName("CMB_Services")
    $SyncHash.TXT_Output = $SyncHash.Form.FindName("TXT_Output")
    $SyncHash.Form.ShowDialog() | Out-Null
    $SyncHash.Error = $Error
    catch{
    write-host $_.Exception.Message
    #End UI_JobScript
    #Begin Main
    add-type -AssemblyName WindowsBase
    [XML]$XAML_Form = @"
    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Resources>
    <DataTemplate x:Key="DTMPL_Name">
    <TextBlock Text="{Binding Path=Name}" />
    </DataTemplate>
    </Window.Resources>
    <DockPanel LastChildFill="True">
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
    <Label Name="LBL_Services" Content="Services:" />
    <ComboBox Name="CMB_Services" ItemTemplate="{StaticResource DTMPL_Name}"/>
    </StackPanel>
    <TextBox Name="TXT_Output"/>
    </DockPanel>
    </Window>
    $SyncHash = [hashtable]::Synchronized(@{})
    $SyncHash.Add("XAML_Form",$XAML_Form)
    $SyncHash.Add("InitialScript", $InitialScript)
    $Normal = [System.Windows.Threading.DispatcherPriority]::Normal
    $UI_Runspace =[RunspaceFactory]::CreateRunspace()
    $UI_Runspace.ApartmentState = [System.Threading.ApartmentState]::STA
    $UI_Runspace.ThreadOptions = [System.Management.Automation.Runspaces.PSThreadOptions]::ReuseThread
    $UI_Runspace.Open()
    $UI_Runspace.SessionStateProxy.SetVariable("SyncHash",$SyncHash)
    $UI_Pipeline = [PowerShell]::Create()
    $UI_Pipeline.Runspace=$UI_Runspace
    $UI_Pipeline.AddScript($UI_JobScript) | out-Null
    $Job = $UI_Pipeline.BeginInvoke()
    $SyncHash.ServiceList = get-service | select name, status | Sort-Object -Property Name
    Function Update-Combobox{
    write-host "`nBegin Update-Combobox [$(get-date)]"
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.ItemsSource = $SyncHash.ServiceList})
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.SelectedIndex = 0})
    write-host "`End Update-Combobox [$(get-date)]"
    Function Update-Textbox([string]$Value){
    write-host "`nBegin Update-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})
    write-host "End Update-Textbox [$(get-date)]"
    Function Read-Textbox(){
    write-host "`nBegin Read-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke($Normal,[action]{$Global:Return = $SyncHash.TXT_Output.Text})
    $Global:Return
    remove-variable -Name Return -scope Global
    write-host "End Read-Textbox [$(get-date)]"
    #Give the form some time to load in the other runspace
    $MaxWaitCycles = 5
    while (($SyncHash.Form.IsInitialized -eq $Null)-and ($MaxWaitCycles -gt 0)){
    Start-Sleep -Milliseconds 200
    $MaxWaitCycles--
    Update-ComboBox
    Update-Textbox -Value $("Initial Load: $(get-date)")
    Write-Host "Value Read From Textbox: $(Read-TextBox)"
    Register-ObjectEvent -InputObject $SyncHash.CMB_Services -EventName SelectionChanged -SourceIdentifier "CMB_Services.SelectionChanged" -action {Update-Textbox -Value $("From Selection Changed Event: $(get-date)")}

    Thanks again for the responses. This may not be possible, but I thought I would throw it out there. I appreciate your help in looking into this.
    To clarify the "Respond to control events in the main runspace"... I'm would like to have an event generated by a form object in the UI runspace (ex: combo box selectionchanged event) trigger a delegate within the main runspace and have that delegate in
    the main runspace update the form in the UI runspace.
    ex:
    1.) User changes selection on combo box generating form event
    2.) Event calls delegate (which I have gotten to work)
    3.) Delegate does some basic processing (works)
    4.) Delegate attempts to update form in UI runspace (hangs)
    As to the delegates / which runspace they are running in. I see the $synchash variable if I run get-var within a delegate, but I do not see the $Form variable so I am assuming that they are in the main runspace. Do you agree with that assumption?

  • Applet Event Handler

    Would someone please help me. I am new to applet development and I get a compile error associated with the event handling in my first ever applet code as follows:
    C:\j2sdk1.4.2_01\bin>javac trajectory_j.java
    trajectory_j.java:248: illegal start of expression
    private class Handler implements ActionListener {
    ^
    trajectory_j.java:248: ';' expected
    private class Handler implements ActionListener {
    ^
    2 errors
    de.
    This is the code:
    // trajectory Analysis Program: trajectory_j.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class trajectory_j extends JApplet implements ActionListener {
         private JTextArea introductionArea, resultsArea;
         private JLabel spanLabel, chordLabel,
              thicknessLabel, massLabel, altitudeLabel, velocityLabel,
              trajectory_angleLabel, time_incrementLabel, rotation_factorLabel,
              calculationLabel, resultsLabel;
         private JTextField spanField, chordField, thicknessField,
              massField, altitudeField, velocityField, trajectory_angleField,
              time_incrementField, rotation_factorField;
         private JButton startButton, resetButton, contButton, termButton;
         String introduction_string, span_string, chord_string, thickness_string, mass_string,
              altitude_string, velocity_string, trajectory_angle_string,
              time_increment_string, rotation_factor_string, results_string;
         double span, chord, thickness, mass, altitude, velocity, trajectory_angle, time_increment,
              rotation_factor, distance, velocity_fps, elapsed_time;
         int status_a;
         int status_b;
         int status_c;
    /* deletion of code segment a
              span = 0;
              chord = 0;
              thickness = 0;
              mass = 0;
              altitude = 0;
              velocity = 0;
              trajectory_angle = 0;
              time_increment = 0;
              rotation_factor = 0;
              distance = 0;
              velocity_fps = 0;
              elapsed_time = 0;
              velocity_fps = 0;
              elapsed_time = 0;
         // create objects
         public void init()
              status_a = 0;
              status_b = 0;
              status_c = 0;
              // create container & panel
              Container container = getContentPane();     
              Panel panel = new Panel( new FlowLayout( FlowLayout.LEFT));
              container.add( panel );
              // set up vertical boxlayout
              Box box = Box.createVerticalBox();
              Box inputbox1 = Box.createHorizontalBox();
              Box inputbox2 = Box.createHorizontalBox();
              Box inputbox3 = Box.createHorizontalBox();
              Box buttonbox = Box.createHorizontalBox();
              introduction_string = "This is the introduction";
              // set up introduction
              introductionArea = new JTextArea( introduction_string, 10, 50 );
              introductionArea.setEditable( false );
              box.add( new JScrollPane( introductionArea ) );
              box.add( Box.createVerticalStrut (10) );
              box.add( inputbox1);
              // set up span
              spanLabel = new JLabel( "span (feet)" );
              spanField = new JTextField(5 );
              inputbox1.add( spanLabel );
              inputbox1.add( spanField );
              Dimension minSize = new Dimension(5, 15);
              Dimension prefSize = new Dimension(5, 15);
              Dimension maxSize = new Dimension(Short.MAX_VALUE, 15);
              inputbox1.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up chord
              chordLabel = new JLabel( "chord (feet)" );
              chordField = new JTextField(5 );
              inputbox1.add( chordLabel );
              inputbox1.add( chordField );
              inputbox1.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up thickness
              thicknessLabel = new JLabel( "thickness (feet)" );
              thicknessField = new JTextField(5 );
              inputbox1.add( thicknessLabel );
              inputbox1.add( thicknessField );
              inputbox1.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up mass
              massLabel = new JLabel( "mass (slugs)" );
              massField = new JTextField(5);
              inputbox1.add( massLabel );
              inputbox1.add( massField );
              box.add( Box.createVerticalStrut (10) );
              box.add( inputbox2);
              // set up altitude
              altitudeLabel = new JLabel( "altitude (feet)");
              altitudeField = new JTextField(5 );
              inputbox2.add( altitudeLabel );
              inputbox2.add( altitudeField );
              inputbox2.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up velocity
              velocityLabel = new JLabel( "velocity (Mach Number)");
              velocityField = new JTextField(5);
              inputbox2.add( velocityLabel );
              inputbox2.add( velocityField );
              inputbox2.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up trajectory_angle
              trajectory_angleLabel = new JLabel( "trajectory angle ( -90 degrees <= trajectory angle <= 90 degrees )");
              trajectory_angleField = new JTextField(5);
              inputbox2.add( trajectory_angleLabel );
              inputbox2.add( trajectory_angleField );
              box.add( Box.createVerticalStrut (10) );
              box.add( inputbox3);
              Dimension minSizeF = new Dimension(70, 15);
              Dimension prefSizeF = new Dimension(70, 15);
              Dimension maxSizeF = new Dimension(Short.MAX_VALUE, 15);
              inputbox3.add(new Box.Filler(minSizeF, prefSizeF, maxSizeF));
              // set up time_increment
              time_incrementLabel = new JLabel( "time increment (seconds)" );
              time_incrementField = new JTextField(5);
              inputbox3.add( time_incrementLabel );
              inputbox3.add( time_incrementField );
              inputbox3.add(new Box.Filler(minSizeF, prefSizeF, maxSizeF));
              // set up rotation_factor
              rotation_factorLabel = new JLabel( "rotation factor ( non-negative number)" );
              rotation_factorField = new JTextField(5);
              inputbox3.add( rotation_factorLabel );
              inputbox3.add( rotation_factorField );
              inputbox3.add(new Box.Filler(minSizeF, prefSizeF, maxSizeF));
              box.add( Box.createVerticalStrut (10) );
              box.add( buttonbox);
              // set up start
              startButton = new JButton( "START" );
              buttonbox.add( startButton );
              Dimension minSizeB = new Dimension(10, 30);
              Dimension prefSizeB = new Dimension(10, 30);
              Dimension maxSizeB = new Dimension(Short.MAX_VALUE, 30);
              buttonbox.add(new Box.Filler(minSizeB, prefSizeB, maxSizeB));
              // set up reset
              resetButton = new JButton( "RESET" );
              buttonbox.add( resetButton );
              buttonbox.add(new Box.Filler(minSizeB, prefSizeB, maxSizeB));
              // set up cont
              contButton = new JButton( "CONTINUE" );
              buttonbox.add( contButton );
              buttonbox.add(new Box.Filler(minSizeB, prefSizeB, maxSizeB));
              // set up term
              termButton = new JButton( "END" );
              buttonbox.add( termButton );
              box.add( Box.createVerticalStrut (10) );          
              // set up results
              resultsArea = new JTextArea( results_string, 10, 50 );
              resultsArea.setEditable( false );
              box.add( new JScrollPane( resultsArea ) );
              // add box to panel
              panel.add( box );
              // register event handlers
              Handler handler = new Handler();
              spanField.addActionListener( handler );
              chordField.addActionListener( handler );          
              thicknessField.addActionListener( handler );
              massField.addActionListener( handler );
              altitudeField.addActionListener( handler );
              velocityField.addActionListener( handler );          
              trajectory_angleField.addActionListener( handler );
              time_incrementField.addActionListener( handler );
              rotation_factorField.addActionListener( handler );
              startButton.addActionListener( handler );
              resetButton.addActionListener( handler );
              contButton.addActionListener( handler );
              termButton.addActionListener( handler );
    // private inner class for event handling
    private class Handler implements ActionListener {
         // process handler events
         public void actionPerformed( ActionEvent event )
              // process resetButton event
              if ( event.getSource() == resetButton )
                   reset();
              // process contButton event
              if ( event.getSource() == contButton )
                   cont();
              // process endButton event
              if ( event.getSource() == termButton )
              // process span event
              if( event.getSource() == spanField ) {
                   span = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( span_string );
                   status_b++;
              // process chord event
              if( event.getSource() == spanField ) {
                   span = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( chord_string );
                   status_b++;     
              // process thickness event
              if( event.getSource() == thicknessField ) {
                   thickness = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( thickness_string );     
                   status_b++;
              // process mass event
              if( event.getSource() == massField ) {
                   mass = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( mass_string );
                   status_b++;     
              // process altitude event
              if( event.getSource() == altitudeField ) {
                   altitude = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( altitude_string );     
                   status_b++;
              // process velocity event
              if( event.getSource() == velocityField ) {
                   velocity = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( velocity_string );
                   status_b++;
              // process trajectory_angle event
              if( event.getSource() == trajectory_angleField ) {
                   trajectory_angle = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( trajectory_angle_string );
                   status_b++;
              // process time_increment event
              if( event.getSource() == time_incrementField ) {
                   time_increment = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( time_increment_string );
                   status_b++;
              // process rotation_factor event
              if( event.getSource() == rotation_factorField ) {
                   rotation_factor = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( rotation_factor_string );
                   status_b++;
              // process startButton event
              if ( event.getSource() == startButton && status_b == 9 ) {
                   status_c = 1;
         } // end method event handler
    } // end Handler class
         } // end method init
         public void strtb()
    /* deletion of code segment 1
              startButton.addActionListener(
                   new ActionListener() {  // anonymous inner class
                        // set text in resultsArea
                        public void actionPerformed( ActionEvent event )
                        if( status_c == 1 ){
                        calculate();
                        results();
                        resultsArea.setText( results() );
    /* deletion of code segment 2                    
                        }// end method actionPerformed1
                   } // end anonymous inner class1
              ); // end call to addActionlistener1
         } // end method strtb
         public void reset()
    /* deletion of code segment 3
              resetButton.addActionListener(
                   new ActionListener() {  // anonymous inner class
                        // set text in resultsArea
                        public void actionPerformed( ActionEvent event )
                        span_string = "";
                        chord_string = "";
                        thickness_string = "";
                        mass_string = "";
                        altitude_string = "";
                        velocity_string = "";
                        trajectory_angle_string = "";
                        time_increment_string = "";
                        rotation_factor_string = "";
                        results_string = "";
                        spanField.setText( span_string );
                        chordField.setText( chord_string );
                        thicknessField.setText( thickness_string );
                        massField.setText( mass_string );
                        altitudeField.setText( altitude_string );
                        velocityField.setText( velocity_string );
                        trajectory_angleField.setText( trajectory_angle_string );
                        time_incrementField.setText( time_increment_string );
                        rotation_factorField.setText( rotation_factor_string );
    resultsArea.setEditable( true );
                        resultsArea.setText( results_string );
    resultsArea.setEditable( false );
                        span = 0;
                        chord = 0;
                        thickness = 0;
                        mass = 0;
                        altitude = 0;
                        velocity = 0;
                        trajectory_angle = 0;
                        time_increment = 0;
                        rotation_factor = 0;
                        distance = 0;
                        velocity_fps = 0;
                        elapsed_time = 0;
    /* deletion of code segment 4               
                        } // end method actionPerformed2
                   } // end anonymous inner class2
              ); // end call to addActionlistener2
         } // end method reset
         public void cont()
         //later
         public void calculate()
         distance = 1;
         altitude = 2;
         trajectory_angle = 3;
         velocity_fps = 4;
         elapsed_time = 5;
         public String results()
         results_string =
         "Distance =\t\t" + distance + " miles\n"
         + "Altitude =\t\t" + altitude + " feet\n"
         + "Trajectory Angle =\t" + trajectory_angle + " degrees\n"
         + "Velocity =\t\t" + velocity_fps + " feet per second\n"
         + "Elapsed Time =\t\t" + elapsed_time + " seconds\n"
         + "\nstatus_a = " + status_a + "\nstatus_b = "
         + status_b + "\nstatus_c = " + status_c;
         return results_string;
    public void start()
    if(status_a == 0 )
    strtb();
    if (status_b == 0)
    reset();
    }// end method start
    } //end class trajectory_a

    The following are copies of html and java source code files for a prior runnable version ( trajectory_b ) of this program which can enlighten some functionality intended by the program.
    (trajectory_b.html):
    <html>
    <appletcode = "trajectory_b.class" width = "800" height = "600">
    </applet>
    </html>
    (trajectory_b.java):
    // trajectory Analysis Program: trajectory_b.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class trajectory_b extends JApplet implements ActionListener {
         private JTextArea introductionArea, resultsArea;
         private JLabel spanLabel, chordLabel,
              thicknessLabel, massLabel, altitudeLabel, velocityLabel,
              trajectory_angleLabel, time_incrementLabel, rotation_factorLabel,
              calculationLabel, resultsLabel;
         private JTextField spanField, chordField, thicknessField,
              massField, altitudeField, velocityField, trajectory_angleField,
              time_incrementField, rotation_factorField;
         private JButton startButton, resetButton, contButton, termButton;
         String introduction_string, span_string, chord_string, thickness_string, mass_string,
              altitude_string, velocity_string, trajectory_angle_string,
              time_increment_string, rotation_factor_string, results_string;
         double span, chord, thickness, mass, altitude, velocity, trajectory_angle, time_increment,
              rotation_factor, distance, velocity_fps, elapsed_time;
         int status_a;
         int status_b;
         int status_c;
    /* deletion of code segment a
              span = 0;
              chord = 0;
              thickness = 0;
              mass = 0;
              altitude = 0;
              velocity = 0;
              trajectory_angle = 0;
              time_increment = 0;
              rotation_factor = 0;
              distance = 0;
              velocity_fps = 0;
              elapsed_time = 0;
              velocity_fps = 0;
              elapsed_time = 0;
         // create objects
         public void init()
              status_a = 0;
              status_b = 0;
              status_c = 0;
              // create container & panel
              Container container = getContentPane();     
              Panel panel = new Panel( new FlowLayout( FlowLayout.LEFT));
              container.add( panel );
              // set up vertical boxlayout
              Box box = Box.createVerticalBox();
              Box inputbox1 = Box.createHorizontalBox();
              Box inputbox2 = Box.createHorizontalBox();
              Box inputbox3 = Box.createHorizontalBox();
              Box buttonbox = Box.createHorizontalBox();
              introduction_string = "This is the introduction";
              // set up introduction
              introductionArea = new JTextArea( introduction_string, 10, 50 );
              introductionArea.setEditable( false );
              box.add( new JScrollPane( introductionArea ) );
              box.add( Box.createVerticalStrut (10) );
              box.add( inputbox1);
              // set up span
              spanLabel = new JLabel( "span (feet)" );
              spanField = new JTextField(5 );
              inputbox1.add( spanLabel );
              inputbox1.add( spanField );
              Dimension minSize = new Dimension(5, 15);
              Dimension prefSize = new Dimension(5, 15);
              Dimension maxSize = new Dimension(Short.MAX_VALUE, 15);
              inputbox1.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up chord
              chordLabel = new JLabel( "chord (feet)" );
              chordField = new JTextField(5 );
              inputbox1.add( chordLabel );
              inputbox1.add( chordField );
              inputbox1.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up thickness
              thicknessLabel = new JLabel( "thickness (feet)" );
              thicknessField = new JTextField(5 );
              inputbox1.add( thicknessLabel );
              inputbox1.add( thicknessField );
              inputbox1.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up mass
              massLabel = new JLabel( "mass (slugs)" );
              massField = new JTextField(5);
              inputbox1.add( massLabel );
              inputbox1.add( massField );
              box.add( Box.createVerticalStrut (10) );
              box.add( inputbox2);
              // set up altitude
              altitudeLabel = new JLabel( "altitude (feet)");
              altitudeField = new JTextField(5 );
              inputbox2.add( altitudeLabel );
              inputbox2.add( altitudeField );
              inputbox2.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up velocity
              velocityLabel = new JLabel( "velocity (Mach Number)");
              velocityField = new JTextField(5);
              inputbox2.add( velocityLabel );
              inputbox2.add( velocityField );
              inputbox2.add(new Box.Filler(minSize, prefSize, maxSize));
              // set up trajectory_angle
              trajectory_angleLabel = new JLabel( "trajectory angle ( -90 degrees <= trajectory angle <= 90 degrees )");
              trajectory_angleField = new JTextField(5);
              inputbox2.add( trajectory_angleLabel );
              inputbox2.add( trajectory_angleField );
              box.add( Box.createVerticalStrut (10) );
              box.add( inputbox3);
              Dimension minSizeF = new Dimension(70, 15);
              Dimension prefSizeF = new Dimension(70, 15);
              Dimension maxSizeF = new Dimension(Short.MAX_VALUE, 15);
              inputbox3.add(new Box.Filler(minSizeF, prefSizeF, maxSizeF));
              // set up time_increment
              time_incrementLabel = new JLabel( "time increment (seconds)" );
              time_incrementField = new JTextField(5);
              inputbox3.add( time_incrementLabel );
              inputbox3.add( time_incrementField );
              inputbox3.add(new Box.Filler(minSizeF, prefSizeF, maxSizeF));
              // set up rotation_factor
              rotation_factorLabel = new JLabel( "rotation factor ( non-negative number)" );
              rotation_factorField = new JTextField(5);
              inputbox3.add( rotation_factorLabel );
              inputbox3.add( rotation_factorField );
              inputbox3.add(new Box.Filler(minSizeF, prefSizeF, maxSizeF));
              box.add( Box.createVerticalStrut (10) );
              box.add( buttonbox);
              // set up start
              startButton = new JButton( "START" );
              buttonbox.add( startButton );
              Dimension minSizeB = new Dimension(10, 30);
              Dimension prefSizeB = new Dimension(10, 30);
              Dimension maxSizeB = new Dimension(Short.MAX_VALUE, 30);
              buttonbox.add(new Box.Filler(minSizeB, prefSizeB, maxSizeB));
              // set up reset
              resetButton = new JButton( "RESET" );
              buttonbox.add( resetButton );
              buttonbox.add(new Box.Filler(minSizeB, prefSizeB, maxSizeB));
              // set up cont
              contButton = new JButton( "CONTINUE" );
              buttonbox.add( contButton );
              buttonbox.add(new Box.Filler(minSizeB, prefSizeB, maxSizeB));
              // set up term
              termButton = new JButton( "END" );
              buttonbox.add( termButton );
              box.add( Box.createVerticalStrut (10) );          
              // set up results
              resultsArea = new JTextArea( results_string, 10, 50 );
              resultsArea.setEditable( false );
              box.add( new JScrollPane( resultsArea ) );
              // add box to panel
              panel.add( box );
              // register event handlers
              Handler handler = new Handler();
              spanField.addActionListener( handler );
              chordField.addActionListener( handler );          
              thicknessField.addActionListener( handler );
              massField.addActionListener( handler );
              altitudeField.addActionListener( handler );
              velocityField.addActionListener( handler );          
              trajectory_angleField.addActionListener( handler );
              time_incrementField.addActionListener( handler );
              rotation_factorField.addActionListener( handler );
              startButton.addActionListener( handler );
              resetButton.addActionListener( handler );
              contButton.addActionListener( handler );
              termButton.addActionListener( handler );
    } // end method init
         // process handler events
         public void actionPerformed( ActionEvent event )
              // process resetButton event
              if ( event.getSource() == resetButton )
                   reset();
              // process contButton event
              if ( event.getSource() == contButton )
                   cont();
              // process endButton event
              if ( event.getSource() == termButton )
              // process span event
              if( event.getSource() == spanField ) {
                   span = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( span_string );
                   status_b++;
              // process chord event
              if( event.getSource() == spanField ) {
                   span = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( chord_string );
                   status_b++;     
              // process thickness event
              if( event.getSource() == thicknessField ) {
                   thickness = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( thickness_string );     
                   status_b++;
              // process mass event
              if( event.getSource() == massField ) {
                   mass = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( mass_string );
                   status_b++;     
              // process altitude event
              if( event.getSource() == altitudeField ) {
                   altitude = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( altitude_string );     
                   status_b++;
              // process velocity event
              if( event.getSource() == velocityField ) {
                   velocity = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( velocity_string );
                   status_b++;
              // process trajectory_angle event
              if( event.getSource() == trajectory_angleField ) {
                   trajectory_angle = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( trajectory_angle_string );
                   status_b++;
              // process time_increment event
              if( event.getSource() == time_incrementField ) {
                   time_increment = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( time_increment_string );
                   status_b++;
              // process rotation_factor event
              if( event.getSource() == rotation_factorField ) {
                   rotation_factor = Double.parseDouble( event.getActionCommand() );
                   spanField.setText( rotation_factor_string );
                   status_b++;
              // process startButton event
              if ( event.getSource() == startButton && status_b == 9 ) {
                   strtb();
         } // end method event handler
         public void strtb()
              startButton.addActionListener(
                   new ActionListener() {  // anonymous inner class
                        // set text in resultsArea
                        public void actionPerformed( ActionEvent event )
                        calculate();
                        results();
                        resultsArea.setText( results() );
                        }// end method actionPerformed1
                   } // end anonymous inner class1
              ); // end call to addActionlistener1
         } // end method strtb
         public void reset()
              resetButton.addActionListener(
                   new ActionListener() {  // anonymous inner class
                        // set text in resultsArea
                        public void actionPerformed( ActionEvent event )
                        span_string = "";
                        chord_string = "";
                        thickness_string = "";
                        mass_string = "";
                        altitude_string = "";
                        velocity_string = "";
                        trajectory_angle_string = "";
                        time_increment_string = "";
                        rotation_factor_string = "";
                        results_string = "";
                        spanField.setText( span_string );
                        chordField.setText( chord_string );
                        thicknessField.setText( thickness_string );
                        massField.setText( mass_string );
                        altitudeField.setText( altitude_string );
                        velocityField.setText( velocity_string );
                        trajectory_angleField.setText( trajectory_angle_string );
                        time_incrementField.setText( time_increment_string );
                        rotation_factorField.setText( rotation_factor_string );
    resultsArea.setEditable( true );
                        resultsArea.setText( results_string );
    resultsArea.setEditable( false );
                        span = 0;
                        chord = 0;
                        thickness = 0;
                        mass = 0;
                        altitude = 0;
                        velocity = 0;
                        trajectory_angle = 0;
                        time_increment = 0;
                        rotation_factor = 0;
                        distance = 0;
                        velocity_fps = 0;
                        elapsed_time = 0;
                        } // end method actionPerformed2
                   } // end anonymous inner class2
              ); // end call to addActionlistener2
         } // end method reset
         public void cont()
         //later
         public void calculate()
         distance = 1;
         altitude = 2;
         trajectory_angle = 3;
         velocity_fps = 4;
         elapsed_time = 5;
         public String results()
         results_string =
         "Distance =\t\t" + distance + " miles\n"
         + "Altitude =\t\t" + altitude + " feet\n"
         + "Trajectory Angle =\t" + trajectory_angle + " degrees\n"
         + "Velocity =\t\t" + velocity_fps + " feet per second\n"
         + "Elapsed Time =\t\t" + elapsed_time + " seconds\n"
         + "\nstatus_a = " + status_a + "\nstatus_b = "
         + status_b + "\nstatus_c = " + status_c;
         return results_string;
    public void start()
    if(status_a == 0 )
    strtb();
    if (status_b == 0)
    reset();
    }// end method start
    } //end class trajectory_b

  • Event Handler/Cr​eate User Event bug

    This is a problem I've run into a few times on my system (Win2k) so I finally went back and reproduced it step by step since it wasn't too hard. It causes LabVIEW to crash and exit without saving.
    - Create an Event Handler
    - Place 'Register Events', wire output to dynamic event terminal
    - Place 'Create User Event', wire output to 'Register Events'/User Event
    - Place an Empty String Constant [""], wire to input of 'Create User Event'
    - Set empty string property -> Visible Items > Label = True
    - Rename label from "Empty String Constant" to other such as "Event"
    OR
    - Create a cluster constant with something in it
    OR
    - Place a boolean constant
    - Set boolean property -> Visible Items > Label = True
    - Name label something su
    ch as "Event"
    - 'Add Event Case...' to the Event Handler, select Dynamic / : User Event
    - Delete the constant wired to 'Create User Event'.
    - Place a constant of a different data type and wire it to the input of 'Create User Event'
    LabVIEW immediately disappears (all changes are lost) and this error is displayed:
    ================================
    LabVIEW.exe has generated errors and will be closed by
    Windows. You wlil need to restart the program.
    An error log is being created.
    ================================
    If there is a more appropriate place to post things of this nature that don’t really add to the discussion group, but need to be brought to the attention of NI, please post a URL or submittal method. Thanks...

    Thanks for the detailed request. We are aware of this exact issue, and the problem was actually fixed for LabVIEW 7.0 for Mac/Unix. Unfortunately, it did not get fixed for the initial release of LabVIEW 7.0 for Windows, but we have plans to include the fix in the first LabVIEW patch for 7.0.
    Also, the Discussion Forum is great for notifications of this kind. For future reference, you also have the options of emailing NI engineers directly, or calling us with suspected bug fixes, if you would like more direct communication.
    Thanks again, and have a great day!
    Liz Fausak
    Applications Engineer
    National Instruments
    www.ni.com/support

  • Event handling in Dynpage

    Hi all,
    This is my first post in SDN.
    Can any one tell me how to submit a form in DYNPAGE via radio button. If I check the radio button on, it should submit the form and should return the same page.
    Appreciate you help.
    Thanks,
    Karthik

    Hi,
    The following code regarding Event Handling for Dynpage. May be this example code useful for you.
    package com.customer.training;
    import com.sapportals.htmlb.Button;
    import com.sapportals.htmlb.Component;
    import com.sapportals.htmlb.DropdownListBox;
    import com.sapportals.htmlb.Form;
    import com.sapportals.htmlb.FormLayout;
    import com.sapportals.htmlb.GridLayout;
    import com.sapportals.htmlb.InputField;
    import com.sapportals.htmlb.Label;
    import com.sapportals.htmlb.TextView;
    import com.sapportals.htmlb.enum.ButtonDesign;
    import com.sapportals.htmlb.enum.TextViewDesign;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    public class Suresh_SearchDynPage extends PageProcessorComponent {
      public DynPage getPage() {
        return new Suresh_SearchDynPageDynPage();
      public static class Suresh_SearchDynPageDynPage extends DynPage {
         public int flag ;
         public final static int disp_info = 1;
         public final static int read_info = 2;
         public final static int error_info = 3;
         public static String flag_info = "MyFlag";
         public static String disp_drop = " ";
         public String errorMessage;
           String firstName ;
           String lastName ;
           String Email ;
           String dropsel;
    Initialization code executed once per user.
        public void doInitialization() {
                        flag = read_info;          
                        IPageContext ctx = this.getPageContext();
                        ctx.setAttribute("FirstName","");
                        ctx.setAttribute("LastName","");
                        ctx.setAttribute("email","");     
    Input handling code. In general called the first time with the second page request from the user.
        public void doProcessAfterInput() throws PageException {
              Component comp;
              comp = this.getComponentByName("FirstName");
              if (comp instanceof InputField)
                        firstName = ((InputField) comp).getString().getValue();
              comp = this.getComponentByName("LastName");
              if (comp instanceof InputField)
                                  lastName = ((InputField) comp).getString().getValue();
              comp = this.getComponentByName("email");
                        if (comp instanceof InputField)
                                            Email = ((InputField) comp).getString().getValue();
              comp = this.getComponentByName("DisplayType");
                        if (comp instanceof DropdownListBox)
                             dropsel = ((DropdownListBox) comp).getSelection();          
    // Store the selected values in corresponding field name for nextScreen                         
              IPageContext ctx = this.getPageContext();
              flag = new Integer(ctx.getAttribute(flag_info).toString()).intValue();
              ctx.setAttribute("FirstName",firstName);
              ctx.setAttribute("LastName",lastName);
              ctx.setAttribute("email",Email);
              ctx.setAttribute("DisplayName",dropsel);                                   
    Create output. Called once per request.
        public void doProcessBeforeOutput() throws PageException {
          Form myForm = this.getForm();
           this.getPageContext().setAttribute(flag_info,new Integer(flag));
         switch(flag)
          case read_info:
                    FormLayout f1 = new FormLayout();
                    TextView t1 = new TextView();
                    t1.setDesign(TextViewDesign.HEADER2);
                    t1.setText("This is the Info U Entered................");
                    TextView t2 = new TextView();
                    t2.setText(firstName);
                    Label dispFname = new Label("dispFirstName");
                    dispFname.setText("First Name");
                    dispFname.setLabelFor(t2);
                    TextView t3 = new TextView();
                    t3.setText(lastName);
                    Label dispLname = new Label("dispLastName");
                    dispLname.setText("Last Name");
                    dispLname.setLabelFor(t3);
                    TextView t4 = new TextView();
                    t4.setText(Email);
                    Label dispEmail = new Label("dispEmail");
                    dispEmail.setText("Email");
                    dispEmail.setLabelFor(t4);
                    TextView t5 = new TextView();
                    t5.setText(dropsel);
                    Label dispType = new Label("dispInfo");
                    dispType.setText("Display Info");
                    dispType.setLabelFor(t5);
                    Button btnback = new Button("Back");
                    btnback.setText("Back");
                    btnback.setOnClick("Back");
                    f1.addComponent(1,1,t1);
                    f1.addComponent(2,1,dispFname);
                    f1.addComponent(2,2,t2);
                    f1.addComponent(3,1,dispLname);
                    f1.addComponent(3,2,t3);
                    f1.addComponent(4,1,dispEmail);
                    f1.addComponent(4,2,t4);
                    f1.addComponent(5,1,dispType);
                    f1.addComponent(5,2,t5);
                    f1.addComponent(6,1,btnback);
                    myForm.addComponent(f1);
               break;
          case error_info:
                    FormLayout f2 = new FormLayout();
                    IPageContext ctx = this.getPageContext();
                    TextView t6 = new TextView();
                    t6.setText("Error : ");
                    t6.setDesign(TextViewDesign.HEADER2);
                    t6.setText(errorMessage);
                    f2.addComponent(3,1,t6);
                    myForm.addComponent(f2);
               break;
                default:
                              // create your GUI here....
                                        GridLayout g1 = new GridLayout();
    //                                    IPageContext ctx1 = this.getPageContext();
                                        Label first_l = new Label("First Name");
                                        InputField first_if = new InputField("FirstName");
                                        Label last_l  =  new Label("Last Name");
                                        InputField last_if = new InputField("LastName");
                                        Label email_l = new Label("E-Mail Address");
                                        InputField email_if = new InputField("email");
                                        Label info_l = new Label("Display Info for");
                                        DropdownListBox displayType = new DropdownListBox("DisplayType");
                                        displayType.addItem("userinfo", "User Info");
                                        displayType.addItem("groupinfo", "Group Membership");
                                        displayType.addItem("roleinfo", "Role Assignment");     
    //                                    displayType.setSelection(ctx1.getAttribute("DisplayType").toString());
                                        Button btn = new Button("submit");            
                                        btn.setText("Get Info");
                                        btn.setDesign(ButtonDesign.EMPHASIZED);
                                        btn.setOnClick("Get");
    //                                    add the ui controls to grid
                                        g1.setCellPadding(4);
                                        g1.addComponent(1,1,first_l);
                                        g1.addComponent(1,2,first_if);
                                        g1.addComponent(2,1,last_l);
                                        g1.addComponent(2,2,last_if);
                                        g1.addComponent(3,1,email_l);
                                        g1.addComponent(3,2,email_if);
                                        g1.addComponent(4,1,info_l);
                                        g1.addComponent(4,2,displayType);
                                        g1.addColSpanComponent(5,1,btn,2);
                                        g1.setHeightPercentage(50);
                                        g1.setColumnSize(50);
                                        myForm.setFocusedControl(displayType);
                                        myForm.setMessageBarAtFormEnd(true);
                                        myForm.setWidthInHundredPercent(true);
                                        myForm.addComponent(g1);     
                                        break;
        public void onGet(Event e)
         if(firstName.length()== 0)
              flag = error_info;
              errorMessage = "Invalid Input..............";
         else
              flag = read_info;
          public void onBack(Event e1)
                flag = disp_info;

  • Event handling in alv oops With buttons

    Hi Experts
             I have some doubt in ALV OOPS using Events. Could any one please tell me the procedure to how to handle events in oops ( Like  interactive reports using events ).
                                     Thank you                                                                               
    Satyendra.

    Hello Satyendra
    The following sample report shows you how to handle the event HOTSPOT_CLICK and BUTTON_CLICK.
    DATA:  gd_okcode TYPE ui_func,
      gt_fcat TYPE lvc_t_fcat,
      go_docking TYPE REF TO cl_gui_docking_container,
      go_grid1 TYPE REF TO cl_gui_alv_grid.
    DATA:   gt_knb1 TYPE STANDARD TABLE OF knb1.
    PARAMETERS: p_bukrs TYPE bukrs  DEFAULT '2000'  OBLIGATORY.
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender,  " grid instance that raised the event
          handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
            IMPORTING
              es_col_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_hotspot_click.
    *   define local data
        DATA:
          ls_knb1     TYPE knb1,
          ls_col_id   TYPE lvc_s_col.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        CASE e_column_id-fieldname.
          WHEN 'KUNNR'.
            SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
            SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
            CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
          WHEN 'ERNAM'.*       
             SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
            CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
        ENDCASE.
    *   Set active cell to field BUKRS otherwise the focus is still on
    *   field KUNNR which will always raise event HOTSPOT_CLICK
        ls_col_id-fieldname = 'BUKRS'.
        CALL METHOD go_grid1->set_current_cell_via_id
          EXPORTING
            is_row_id    = e_row_id
            is_column_id = ls_col_id.
    ENDMETHOD.                    "handle_hotspot_click
    METHOD handle_button_click.
    *   define local data
        DATA:
          ls_knb1     TYPE knb1.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX es_row_no-row_id.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
        SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
        CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
      ENDMETHOD.                    "handle_button_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = p_bukrs
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_docking
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_hotspot_click FOR go_grid1,
        lcl_eventhandler=>handle_button_click  FOR go_grid1.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog_knb1.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = gt_knb1
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          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.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          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.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    FORM build_fieldcatalog_knb1 .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNB1'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    LOOP AT gt_fcat INTO ls_fcat
              WHERE ( fieldname = 'KUNNR'  OR
                      fieldname = 'ERNAM'  OR
                      fieldname = 'BUKRS' ).
        IF ( ls_fcat-fieldname = 'BUKRS' ).
          ls_fcat-style = cl_gui_alv_grid=>mc_style_button.  " column appears as button
        ELSE.
          ls_fcat-hotspot = abap_true.
        ENDIF.
        MODIFY gt_fcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    Regards
      Uwe

  • Event Handling in labview with arrays as event data

    Hey folks,
    I have a Labview Application which uses a dll to read Ethernet data. The setup is such that, when the dll has fresh data it sends out an event to the Labview Application so that the fresh data can be displayed.
    However i have only managed to get this event based mechanism to send out a single structure at a time. Hence if there are 10 fresh data values, i need to send out 10 events (each event structure contains the parameter name, parameter value, unit and time stamp). It would be more efficient to send out an array of structures in a sigle shot.
    I have tried this but Labview keeps crashing saying that an error was encountered and Labview needs to close along with an access violation message. I did a lot of online searching and found some LV code for event handling but not come accross any implementation which uses arrays as evend data. Is this supoorted? And if so is there any example vi that can be shared so that i get some knowledge about this.
    Many Thanks in adavance,
    Abel. 

    I also gave a try by using a variant as the event data type instead of the cluster which contains the array of floats. I converted the cluster into a variant and used that to create the user event reference. Followed the same logic while decoding the dats.
    But still the crash.... Here is the windbg output...
    ModLoad: 07580000 075b7000 C:\Program Files\National Instruments\LabVIEW 2012\resource\lvalarms.dll
    ModLoad: 0ca90000 0cb72000 C:\Program Files\National Instruments\LabVIEW 2012\resource\mesa.dll
    ModLoad: 0c7f0000 0c7f9000 C:\Program Files\National Instruments\LabVIEW 2012\resource\lvuste.dll
    ModLoad: 35000000 3509b000 C:\Program Files\National Instruments\Shared\TDMS\tdms.dll
    ModLoad: 0c860000 0c87c000 D:\SapphireViewer\dll\SapphireClientDll.dll
    ModLoad: 0e240000 0e2c7000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86\MSVCP80.dll
    ModLoad: 0e2d0000 0e36b000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_44262b86\MSVCR80.dll
    (1cb0.1a34): Access violation - code c0000005 (first chance)
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    eax=0e47f8b4 ebx=051f0040 ecx=051f0040 edx=061e5764 esi=22820840 edi=07b10040
    eip=03c2050c esp=0e47f5cc ebp=0e47f810 iopl=0 nv up ei pl nz na po nc
    cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010202
    *** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\National Instruments\LabVIEW 2012\resource\tdcore_12_0.dll -
    tdcore_12_0!LvVariant:etContents+0xac:
    03c2050c 837e3100 cmp dword ptr [esi+31h],0 ds:0023:22820871=????????
    I cannot really tell whats going on. Looking for some pointers.
    Regards,
    Abel.

  • Event handling in Network UI element in Webdynpro

    Hi ,
       I am developing a hierarchial graph using Network UI element.I want to incorporate event handling so that the graph will respond to user actions like on double clicking a node an URL will be opened.I can notproceed with the event handling.
                         Can anyone tell me the procedure to do this from webdynpro java.
    Regards
    Nayeem

    Hi Nayeem,
    The Network UI element has lots of events defined for it which can be handled to get the desired functionality.
    Go to the View in which you have added the Network Element, select the Element and go to the
    properties tab.
    Under events , you can see a list of events defined for this UI element.
    Select the event you wish to handle and press the Create button which gets visible once
    an event say onNodeSelected is selected
    You can then give a name to the action say UserClicked and save it .
    In the properties tab of the UI element , the action will be registed against the event .
    Now select the event again and press the go button.
    It will redirect you to the java editor of the view where in you can place your event handling logic.
    Alternatively, if you have created the UI element dynamically then you can add the event to the UI element by using the following code
    IWDNetwork network = (IWDNetwork)view.createElement(IWDNetwork.class);
    network.setOnNodeSelected(/*Your Action handler already defined in the View*/);
    Regards,
    Ashish

Maybe you are looking for

  • How can I sync my outlook to icloud calendar?

    I have an iphone 4 and was wondering how I would sync my outlook office 365 calendar with my icloud calendar?

  • How do I save and email a contact sheet in LR5

    Hello - I am using LR 5.6 and am trying to create, save as a JPG or PDF a contact sheet to then be able to email to a client. There has to be a way to do this - used to do it in PS easily. Thanks in advance. Joe

  • Can't use bind variable in a function

    This is a repost from my earlier post at URGENT: Problem creating the report using Procedure The problem is when I bind a variable in a function, I get REP-0002. Please look at the following steps to reproduce === set serveroutput on create or replac

  • Need help with Maze creation

    Hi everyone! I'm currently trying to make a maze creator program. My problem is that it's not functioning properly, though i can't find any problems in the theory. since the program is not 10 lines long i don't want to post the whole program here, so

  • Delete this Skype Name from the Skype directory

    Please delete my skype account.....I already delete all information from my profile as described in below mentioned link.. (https://support.skype.com/en/faq/FA142/how-can-i-d​elete-my-skype-account) I want to delete this Skype Name from the Skype dir