Use of events and interface in class

Dear All,
Could you please explain why we use events and interface in class.
Also please tell me the use of TRY and ENDTRY.
Regards,
Amar

Events may be a way of communication b/w classes. Imagine you want to call certain code from one class, you would need for that public method, but you don't want to expose it to external user. So you may use events for that. Also events are used to notify that certain state of class has changed (tiggering event). Then all handlers of this event executes and react accordingly.
Interfaces are a way of provide a service to class which implements it. Imagine that you have class office and hotel and gas station . They don't seems to have something in common. However, there can be some external energy provider which will be an interface. Each class which want to have a lease with this energy provided can implement it (the implementation can differ in some way), so he can provided energy to different classes. This way you will achieve polimorphism (meaning you call one interface method, but code behind it differs from class to class).
Interfaces are also means of multiple inheritance. One class can implement several service (interfaces). In contrary it can oly inherit from one class.
Try endtry are just new way of handling exceptions .
Try to search a litte bit you will find lots of info on the above.
Regards
Marcin

Similar Messages

  • How to use the eventing and databag with a WAS 6.20 ?

    How to use the eventing and databag with a WAS 6.20 ?
    Is what there is a good guide for these services?
    Thank's

    In the raise event you can pass the value
    like below.
    <SCRIPT>
    function raiseEvt(value1){
    if(window.document.domain == window.location.hostname){
    if ( document.domain.indexOf(".") > 0 ) document.domain = document.domain.substr(document.domain.indexOf(".")+1);
       EPCMPROXY.raiseEvent( "urn:com.sap:BWEvents","BWiViewevent", value1, null );
      // alert('tree domain'+document.domain);
    </SCRIPT>
    and in the
    subscribe event you can get the values like below.
    <script language="javascript">
    if(window.document.domain == window.location.hostname){
    document.domain = document.domain.substring(document.domain.indexOf('.')+1);
        EPCMPROXY.subscribeEvent("urn:com.sap:BWEvents","BWiViewevent", window, "myreceiveEvent");
    function myreceiveEvent( eventObj ) {
          document.forms[0].gp_hidden.value = eventObj.dataObject;
    </script>
    Also look at the following link for a complete documentation.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/Enterprise%20Portal%20Client.pdf
    Regards
    Raja

  • Sample prog's on LDB using Get events and also using LDB_PROCESS

    Hello,
    Can any one send me programs on LDB by linking it to an executable program using get event and also by using the Function Module LDB_ PROCESS.
    Please do not provide me the Example prog's available in SAP HELP
    If you have any sample prog's then please provide them.
    Have a great day!
    Thanks & Regards,
    Krishna Chaitanya

    hi,
    A sample prog with LDB PNP
    *& Report ZH_REPT_PAYMENT *
    report zh_rept_payment line-size 80 no standard page
    heading.
    tables: pernr, " Standard Selections for HR Master Data Reporting
    pcl1, " HR Cluster 1
    pcl2, " HR Cluster 2
    pa0009,
    PA9001,
    PA9006,
    pa0002,
    pc260 , " Cluster Directory for Payroll Results
    bnka .
    Infotypes
    infotypes: 0001. " Organizational Assignment
    Declaration of Internal Tables
    data : bnka1 like bnka occurs 0 with header line .
    data: begin of t_int_rep occurs 100,
    bankl like pc209-bankl, " Bank Number
    zlsch like pc209-zlsch, " Payment method
    pernr like pernr-pernr, " Employee Number
    ename like pernr-ename, " Employee Name
    bankn like pc209-bankn, " Bank Account Number
    betrg like pc209-betrg, " Amount to be transfered
    zweck like pa0009-zweck, " Purpose
    end of t_int_rep.
    data: begin of int_rep occurs 100,
    bankl like pc209-bankl, " Bank Number
    zlsch like pc209-zlsch, " Payment method
    pernr like pernr-pernr, " Employee Number
    ename like pernr-ename, " Employee Name
    bankn like pc209-bankn, " Bank Account Number
    betrg like pc209-betrg, " Amount to be transfered
    zweck like pa0009-zweck, " Purpose
    begda like pa0009-begda, "Begin date
    end of int_rep.
    Declaration of Data Variables
    data: ws_betrg like pc209-betrg, " BT Amount
    w_val like spell occurs 0 with header line,
    int_rep1(6), " TYPE I, " Employee Number
    cnt type i value 0, " Counter
    calcmolga like t500l-molga value '40', " Country Grouping
    v_id(15),
    calc_currency like t001-waers value 'INR'. " Currency
    data : ctr type i,
    dt_merge like pa0009-begda.
    data: ws_totemp(6) type c,
    ws_totamt(20) type c,
    r_mth(9) type c,
    ws_fpbeg(6) type c,
    ws_fpend(6) type c,
    ws_mthyr(6) type c,
    ws_mthyr_r(14) type c,
    r_mth_t(3) type c,
    ws_amt(8) type c,
    ws_bankl(14) type c,
    ws_date(6) type c,
    amount_word(500),
    total_page type i,
    pages type i,
    remain type i.
    data begin of i_spell.
    include structure spell .
    data end of i_spell .
    data : c_molga type t500l-molga value '40',
    c_banks type bnka-banks value 'IN'.
    Standard Includes
    include rpc2cd09. "Cluster CD data definition
    include pc2rxin0.
    include rpc2rx09.
    include rpppxd00. " Data Definition buffer PCL1/PCL2
    include rpppxd10. " Common Part buffer PCL1/PCL2
    include rpppxm00. " Buffer Handling RoutinePCL1/PCL2
    include zrpc2rox2. " Data Definition POCLSTERS (not J,K,U)
    Selection Screen
    selection-screen begin of block b1 with frame title text-001.
    parameter: pa_mth(2) type c default sy-datum+4(2) obligatory,
    pa_year(4) type c default sy-datum(4) obligatory,
    p_bankl like pc209-bankl, " Bank Number
    p_zlsch like pc209-zlsch. " Payment method
    selection-screen end of block b1.
    save_calc_currency = calc_currency.
    count_top = 0.
    get_pernr_flag = 0.
    Top-Of-Page
    top-of-page.
    perform convert_month using pa_mth(2) r_mth.
    ws_mthyr_r = r_mth.
    concatenate ws_mthyr_r pa_year into ws_mthyr_r separated by space.
    SKIP 5.
    skip 1.
    skip 4.
    if int_rep-bankl eq ' '.
    if int_rep-zlsch eq 'C' or int_rep-zlsch eq 'E' or
    int_rep-zlsch eq ' '.
    write: /1(85) 'CHEQUE PAYMENT STATEMENT'(047) centered.
    elseif int_rep-zlsch eq 'L'.
    write: /1(85) 'DEMAND DRAFT STATEMENT'(047) centered.
    endif.
    else.
    write: /1(85) 'BANK TRANSFER STATEMENT'(002) centered.
    endif.
    skip.
    write: /34 ws_mthyr_r,
    62 'Page :'(008),69(2) sy-pagno intensified off,
    ' Of ',78(2) pages intensified off.
    clear pages.
    read table bnka1 with key bankl = int_rep-bankl .
    if sy-subrc = 0.
    if int_rep-zlsch eq 'T'.
    write:/03(10) 'Bank Name : ', bnka1-banka.
    write:/03(10) 'Branch : ', bnka1-brnch.
    write:/03(10) 'Address : ', bnka1-stras.
    endif.
    endif.
    skip.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 2(5) 'Sl.No'(002),
    7 sy-vline, 8(8) 'Emp.No.'(003),
    16 sy-vline,17(35) 'Employee Name'(004).
    *--added for Demand Draft
    if ( int_rep-zlsch = 'l' or int_rep-zlsch = 'L' ).
    write : 47 sy-vline, 48(15) 'Payable at'(005).
    else.
    write : 47 sy-vline,48(15) 'Account No.'(005).
    endif.
    write: 63 sy-vline,64(16) 'Amount'(006),
    80 sy-vline.
    write:/1(80) sy-uline.
    end-of-page.
    write:/1(80) sy-uline.
    write:/2 'Printed on ', sy-datum.
    Start-of-selection.
    start-of-selection.
    *perform h_headr.
    ctr = 0.
    set margin 5.
    call function 'RP_GET_CURRENCY'
    exporting
    molga = calcmolga
    importing
    waers = calc_currency
    exceptions
    others.
    if sy-subrc ne 0.
    calc_currency = 'DEM'.
    calc_currency = save_calc_currency.
    endif.
    get pernr.
    cd-key-pernr = pernr-pernr.
    perform import_cluster.
    get_pernr_flag = 1.
    check : ocd-version-molga eq calcmolga.
    The table 'tabpernr' is filled with the personnel numbers
    and is used after selection is finished.
    move-corresponding pernr to tabpernr.
    append tabpernr.
    The table 'tab_rgdir' is filled
    loop at rgdir.
    rx-key-pernr = pernr-pernr.
    unpack rgdir-seqnr to rx-key-seqno.
    perform int_tab. "fill tab_rgdir
    perform import_bt.
    perform validate.
    endloop.
    End of Selection
    end-of-selection.
    *perform h_headr.
    perform convert_date_a using pa_mth r_mth_t.
    sort int_rep by bankl zlsch pernr betrg descending.
    delete adjacent duplicates from int_rep
    comparing bankl zlsch pernr .
    sort int_rep by bankl zlsch bankn . "PERNR.
    loop at int_rep.
    at new bankl.
    select single * into bnka1 from bnka
    where banks = c_banks and
    bankl = int_rep-bankl .
    append bnka1.
    clear bnka1.
    endat.
    endloop.
    for Demand Draft - purpose added
    loop at int_rep.
    concatenate pa_year(4) pa_mth(2) '01' into dt_merge.
    select single * "zweck into int_rep-zweck
    from pa0009 where
    pernr = int_rep-pernr and
    bankl = int_rep-bankl and
    zlsch = int_rep-zlsch
    and begda <= dt_merge and
    endda >= dt_merge .
    if sy-subrc = 0.
    int_rep-zweck = pa0009-zweck.
    modify int_rep.
    endif.
    endloop.
    *-for DD and Chq sorted by PAyable at and EMPNO wise
    if p_zlsch = 'T' .
    sort int_rep by bankl zlsch bankn . "PERNR.
    else. "added for "payable at" for DD/Chq
    else.
    sort int_rep by zweck pernr . "PERNR.
    endif.
    *delete adjacent duplicates from int_rep.
    t_int_rep] = int_rep[.
    loop at int_rep.
    *-for page of page no.
    total_page = 0.
    loop at t_int_rep where bankl = int_rep-bankl
    and zlsch = int_rep-zlsch.
    total_page = total_page + 1.
    endloop.
    pages = total_page div 25.
    remain = total_page mod 25.
    comment bcoz its adding one extra page no.
    done as on 29/11/2004
    if remain > 0.
    pages = pages + 1.
    endif.
    **-end
    at new bankl.
    ctr = 0 .
    new-page.
    endat.
    at new zlsch.
    ctr = 0 .
    new-page.
    endat.
    clear v_id.
    select single natio
    into pa0002-natio
    from pa0002
    where pernr eq int_rep-pernr.
    *-testing......for soma
    if ctr > 24.
    ctr = 0 .
    write:/1(80) sy-uline.
    new-page .
    endif.
    ctr = ctr + 1 .
    cnt = cnt + 1.
    pack int_rep-pernr to int_rep1.
    write:/1 sy-vline, 2(3) cnt intensified off,
    7 sy-vline, 9(6) int_rep1 intensified off,
    16 sy-vline,17(35) int_rep-ename intensified off .
    if ( int_rep-zlsch = 'l' or int_rep-zlsch = 'L' ).
    write : 47 sy-vline,48(15) int_rep-zweck intensified off.
    else.
    write:
    47 sy-vline,48(15) int_rep-bankn intensified off .
    endif.
    write: 63 sy-vline,64(16) int_rep-betrg
    intensified off currency 'INR',
    80 sy-vline.
    ws_betrg = ws_betrg + int_rep-betrg.
    *-testing......for soma
    skip.
    write :
    /1 sy-vline, 7 sy-vline ,16 sy-vline ,47 sy-vline,63 sy-vline,80
    sy-vline .
    *-end testing......for soma
    at end of zlsch.
    if int_rep-bankl = ' '.
    call function 'HR_IN_CHG_INR_WRDS'
    exporting
    amt_in_num = ws_betrg
    importing
    amt_in_words = amount_word
    EXCEPTIONS
    DATA_TYPE_MISMATCH = 1
    OTHERS = 2
    w_val-word = amount_word.
    concatenate 'INR.' w_val-word into w_val-word
    separated by space.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 7 'Total transfer:'(009),
    64(16) ws_betrg intensified off currency 'INR',
    80 sy-vline.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 3 w_val-word+0(76) intensified off,
    80 sy-vline.
    write :/1 sy-vline, 10 w_val-word+76(70) intensified off,
    80 sy-vline.
    write:/1(80) sy-uline.
    clear: ws_betrg,cnt.
    skip 2.
    write: /2 'Prepared by :'(010), '_______________'(013),
    45 'Checked by :'(011),'_______________'(013).
    skip 2.
    write: /2 'Printed On ', sy-datum,
    45 'Approved by :'(012),'_______________'(013).
    clear sy-pagno.
    endif.
    endat.
    at end of bankl.
    if int_rep-bankl ' '.
    call function 'HR_IN_CHG_INR_WRDS'
    exporting
    amt_in_num = ws_betrg
    importing
    amt_in_words = amount_word
    EXCEPTIONS
    DATA_TYPE_MISMATCH = 1
    OTHERS = 2
    w_val-word = amount_word.
    concatenate 'INR.' w_val-word into w_val-word
    separated by space.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 7 'Total transfer:'(009),
    64(16) ws_betrg intensified off currency 'INR',
    80 sy-vline.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 3 w_val-word+0(76) intensified off,
    80 sy-vline.
    write :/1 sy-vline, 10 w_val-word+76(70) intensified off,
    80 sy-vline.
    write:/1(80) sy-uline.
    clear: ws_betrg,cnt.
    skip 2.
    write: /2 'Prepared by :'(010), '_______________'(013),
    45 'Checked by :'(011),'_______________'(013).
    skip 2.
    write: /2 'Printed on ', sy-datum,
    45 'Approved by :'(012),'_______________'(013).
    clear sy-pagno.
    NEW-PAGE.
    endif.
    endat.
    endloop.
    End of Page
    end-of-page.
    write: /2 'Prepared by :'(010), '_______________',
    45 'Checked by :'(011),'_______________'.
    *& Form IMPORT_CLUSTER
    Importing Data from Cluster *
    form import_cluster.
    sy-subrc = 0.
    rp-imp-c2-cd.
    if sy-subrc eq 0.
    if cd-version-number ne ocd-version-number.
    endif.
    endif. " SY-SUBRC EQ 0
    endform. " IMPORT_CLUSTER
    *& Form INT_TAB
    Filling internal table tab_rgdir form int_tab.
    *Fill internal table tab_rgdir.
    move-corresponding rgdir to tab_rgdir.
    tab_rgdir-pernr = pernr-pernr.
    append tab_rgdir.
    endform. " INT_TAB
    *& Form IMPORT_bt
    Import Values from Bank Transactions Table (BT) form import_bt.
    rp-init-buffer.
    RP-IMP-C2-RX.
    rp-imp-c2-in.
    if rp-imp-in-subrc eq 0.
    if in-version-number ne oin-version-number.
    write: / 'Schlüssel des Clusters RX:'(015),
    rx-key-pernr, rx-key-seqno.
    write: / 'The imported version of the cluster'(016), 'RX',
    'is not current'(017).
    write: / 'Imported version :'(018),
    oin-version-number.
    write: / 'Current version of cluster :'(019),
    in-version-number.
    stop.
    else.
    sy-subrc = 0.
    endif.
    else.
    sy-subrc = 8.
    write: /
    'Inconsistencies between cluster directory and directory for'(020).
    write: /
    'No payroll results found for data in cluster directory'(021).
    write : /
    'Please contact hotline to solve the current problem'(022).
    endif.
    ws_fpbeg(2) = versc-fpbeg+4(2).
    ws_fpbeg+2(4) = versc-fpbeg(4).
    ws_fpend(2) = versc-fpend+4(2).
    ws_fpend+2(4) = versc-fpend(4).
    ws_mthyr(2) = pa_mth.
    ws_mthyr+2(4) = pa_year.
    check ws_mthyr = ws_fpbeg.
    check ws_mthyr = ws_fpend.
    loop at bt. "from pc209
    int_rep-pernr = pernr-pernr.
    int_rep-ename = pernr-ename.
    int_rep-bankl = bt-bankl.
    int_rep-bankn = bt-bankn.
    int_rep-betrg = bt-betrg.
    int_rep-zlsch = bt-zlsch.
    append int_rep.
    endloop.
    IF P_BANKL ' ' AND P_ZLSCH ' '.
    DELETE INT_REP WHERE BANKL P_BANKL.
    ELSEIF P_BANKL = ' ' AND P_ZLSCH ' '.
    DELETE INT_REP WHERE ZLSCH P_ZLSCH.
    ELSEIF P_BANKL ' ' AND P_ZLSCH = ' '.
    DELETE INT_REP WHERE BANKL P_BANKL.
    ENDIF.
    endform. " IMPORT_BT
    *& Form CONVERT_MONTH
    Fetching Month Text form convert_month using mth t_mth.
    case mth.
    when '01'.
    t_mth = 'January'(023).
    when '02'.
    t_mth = 'February'(024).
    when '03'.
    t_mth = 'March'(025).
    when '04'.
    t_mth = 'April'(026).
    when '05'.
    t_mth = 'May'(027).
    when '06'.
    t_mth = 'June'(028).
    when '07'.
    t_mth = 'July'(029).
    when '08'.
    t_mth = 'August'(030).
    when '09'.
    t_mth = 'September'(031).
    when '10'.
    t_mth = 'October'(032).
    when '11'.
    t_mth = 'November'(033).
    when '12'.
    t_mth = 'December'(034).
    endcase.
    endform. " CONVERT_MONTH
    *& Form CONVERT_DATE_A
    Fetching Month Text * form convert_date_a using mth_t t_mth_t.
    case mth_t.
    when '01'.
    t_mth_t = 'Jan.'(035).
    when '02'.
    t_mth_t = 'Feb.'(036).
    when '03'.
    t_mth_t = 'Mar.'(037).
    when '04'.
    t_mth_t = 'Apr.'(038).
    when '05'.
    t_mth_t = 'May.'(039).
    when '06'.
    t_mth_t = 'Jun.'(040).
    when '07'.
    t_mth_t = 'Jul.'(041).
    when '08'.
    t_mth_t = 'Aug.'(042).
    when '09'.
    t_mth_t = 'Sep.'(043).
    when '10'.
    t_mth_t = 'Oct.'(044).
    when '11'.
    t_mth_t = 'Nov.'(045).
    when '12'.
    t_mth_t = 'Dec.'(046).
    endcase.
    endform. " CONVERT_DATE_A
    *& Form VALIDATE
    text
    --> p1 text
    <-- p2 text form validate .
    if p_bankl <> ' ' and p_zlsch ' '.
    delete int_rep where bankl p_bankl.
    elseif p_bankl = ' ' and p_zlsch ' '.
    delete int_rep where zlsch p_zlsch.
    elseif p_bankl ' ' and p_zlsch = ' '.
    delete int_rep where bankl p_bankl.
    endif.
    endform. " VALIDATE
    Hope this helps, Do reward.

  • Custom Events and Listeners between classes

    I've got a project I've been working on for weeks that I'm
    having yet another problem with. I'm trying to learn AS3 which is
    why it's taking so long but that's not important for this post.
    I wanted to create a custom event class so that I could make
    sure the event does not interfere with other "COMPLETE" events that
    are being passed between classes. In other words, I have a few
    things that need to complete prior to a function being called...
    one is some XML being loaded and another is a font loaded. So, I
    thought I would create a custom FontLoaded class that extends Event
    and make the type something like "FontLoadedEvent.LOADED". That way
    I could listen for the XML "Event.COMPLETE" and this font event
    also.
    Please tell me if I'm going down the wrong path here but I
    don't seem to be getting the dispatched event for my new custom
    event. Also, how does one detect if it's being dispatched other
    than if the eventListener is fired? Any other ways to test
    this?

    You can trace the event to see if it dispatched.
    Also, this is not a good case to create a new event. Custom
    events are used to store additional information. MouseEvent exists
    because Event doesn't have localX, localY, etc. properties. Since
    you don't seem to be throwing additional properties, you can use a
    regular event.
    trace(dispatchEvent(new Event("panelFontsLoaded"));
    addEventListener("panelFontsLoaded", onFontsLoaded);
    Static consts are used to help debug typos. The event type is
    just a string, often stored in a const.

  • Use of abstract and interface?

    when i use Abstract class or Interface.Which one is better?

    Depends on what you want to do. An interface is more general (in that it doesn't define any actual behavior) and allows you to mimic multiple inheritance (a class can implement any number of interfaces whereas it can only extend one class (abstract or otherwise)). Abstract is good if you have a common base of functionality that all of the implementers will be using.
    It's also fairly common to use both (i.e. the interface TableModel and the abstract class AbstractTableModel), so that someone who wants to completely write their own implementation is free to, while someone who wants to just extend or change the standard functionality could do that as well.

  • Terminating event and abap oo class

    Hi, gurus,
    I 'd like to know how the terminating event works.
    for example,  i define a custom abap oo class (which has been implemented the interface of IF_WORKFLOW), and i want to use it as the terminating event of a standard task.
    could you please tell me how does it works?
    1. there must be an instance defined in the container of the task?
       which must be instanciated in the run time?
    2. then in another abap report, i simply raise the event defined as the terminating event, using the same key, then the pending task will be terminated?
    could you pls provide more information on this ?
    thanks and best regards.
    Jun

    Hi Jun Zhang,
    An event that is used to stop a workflow or task, or change the behavior of an already started workflow is called Terminating Event.
    If the event linkage is active and the linkage rules are satisfied, the status of the work item is set to COMPLETED.
    Defining Event Linkage  Terminating event linkage consists of 2 parts.
    Type linkage which specifies business object type, event name, generic name for event receiver (WORKITEM for terminating events of tasks or EVENTITEM for wait for event steps)
    Instance linkage which identifies the particular receivers (I.e. work item Ids) per object instance.
    Terminating event linkages can be seen in SWE3.
    For terminating events, along with Business object and Event a Container Element should be specified that holds the Object Instance.
    Terminating Event for Workflow is available from Release 6.10 only. This is defined in Basic Data of Workflow Builder.
    Binding Definition is optional for Terminating Events. Binding can be defined b/n event container and workflow container to pass event information to the workflow if required. That is the only way of passing information from an asynchronous method to the task that started it.
    Thanks and Regards,
    Prabhakar Dharmala

  • How to define event hander interface in Class Builder (se24)?

    Hello,
    I've got the following local interface defined.
    INTERFACE lif_alv_grid_event_handler.
      METHODS:
        handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
          IMPORTING es_col_id es_row_no,
        handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row e_column es_row_no,
        handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
          IMPORTING e_row_id e_column_id es_row_no,
        handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING e_object e_interactive,
        handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING e_ucomm.
    ENDINTERFACE.
    Now I want to define it as a dictionary object using se24.
    My problem is I could not find the quivalent of "FOR EVENT"
    word in it.
    Is there any chance to do that in Class Builder?
    Best regards
    Pawel

    Hello Pawel
    Display your class with the event handler methods in SE24 / SE80 and choose the DETAIL button (above the table control with the methods).
    Here you can define a method as "event handler for" an event of another class.
    On SAP release >= 6.20 you can right-click on a method in the tree view and choose context menu function Display -> Definition (tabstrip Attributes ).
    Regards
      Uwe

  • How to use a variable between interfaces or class?

    Hello All;
    Far by now I can say that the forum is very helpful for me. Thanks for all the people who have the time and generosity to help our problems. Thank you.
    Unfortunately I have a problem <Again :( >
    I want to use a variable in two different *.java files.
    Is it possible?
    The Variable i want to use is; int CiftSayisi
    The variable is declared in the CamCalib.Java under a button's Action Listener.
    Here is the code;
    public void actionPerformed(ActionEvent arg0) {
                        ImagePair.main(null);
                        String[] ImPath = list.getItems();                                           //Storing Items in an Array
                        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();                     //Dimensions of the Screen Storing in an object
                        int ScreenHeight = dim.height;                                           //Definition ScreenHeight
                        int ScreenWidth = dim.width;                                          //Definition ScreenWidth
                        // System.out.println(ScreenHeight);                                                    //Testing of the Dimensions
                        // System.out.println(ScreenWidth);                                                     //Testing of the Dimensions
                        int CiftSayisi = ImPath.length -1 ;
                        if (CiftSayisi == 0){
                             System.out.println("Added Images do not Construct a Pair");
                        else {
    }Now i want to use it in another java file which is ImagePair.Java in the loading part of the interface;
                 setType(Type.UTILITY);
              setTitle("Image Pair Selection");
              setResizable(false);
              setAlwaysOnTop(true);
              setBounds(100, 100, 450, 68);
              contentPane = new JPanel();
              contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
              setContentPane(contentPane);
              contentPane.setLayout(null);
              textField = new JTextField();
              textField.setBounds(61, 11, 22, 20);
              textField.setEditable(false);
              textField.setEnabled(false);
              contentPane.add(textField);
              textField.setColumns(2);I have a text field in here that i need to fill with the value of CiftSayisi
    Any help please?
    ömer kaya
    METU-GGIT
    Edited by: Ömer K. on Apr 10, 2012 12:43 AM

    I didn't bother reading the code, since you didn't format it.
    But to answer your question (if I understand it correctly), yes, it is possible to pass variables between different object instances (not from an interface specifically, since interfaces don't have members). The simplest way to pass the variable as an argument to a method or constructor. If these aren't available, you could create a static global variable, though in a multithreaded app you'd have to synchronize access.

  • Please help me ~ use WSDL file and Java Querypage Class

    First, i can't write english very well. so before read this you know.
    i have a project. and oracle suggest "http://www.webbasedcrmsoftware.com.au/crm-on-demand-tutorials/65-java-access-to-crm-on-demand#_Toc224720963 " . Do you know this URL?
    anyway I Along the this URL Explanation. but i have a problem.
    First, please look this source.(that URL same source)
    <Java Source Start(QueryPage(Select?))>
    package crmod;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.util.StringTokenizer;
    public class CRMOD {
    public CRMOD() {
    public static void main(String[] args) {
    String jsessionid, jsessionid_full;
    String endpoint;
    try
    CRMOD crmod = new CRMOD();
    System.out.println("Loggin In");
    jsessionid_full = crmod.logon("https://secure-ausomxana.crmondemand.com/Services/Integration", "MY ID", "MY PASSWORD");
    jsessionid = getSessionId(jsessionid_full);
    System.out.println(jsessionid);
    endpoint = "https://secure-ausomxdsa.crmondemand.com/Services/Integration" + ";jsessionid=" + jsessionid;
    URL urlAddr = new java.net.URL( endpoint);
    crmondemand.ws.contact.Contact service = new crmondemand.ws.contact.ContactLocator();
    crmondemand.ws.contact.Default_Binding_Contact stub = service.getDefault(urlAddr);
    crmondemand.ws.contact.ContactWS_ContactQueryPage_Input contactlist = new crmondemand.ws.contact.ContactWS_ContactQueryPage_Input();
    crmondemand.ws.contact.ContactWS_ContactQueryPage_Output outlist = new crmondemand.ws.contact.ContactWS_ContactQueryPage_Output();
    crmondemand.xml.contact.Contact[] contacts = new crmondemand.xml.contact.Contact[1];
    crmondemand.xml.contact.Contact contact = new crmondemand.xml.contact.Contact();
    crmondemand.xml.contact.Activity[] activities = new crmondemand.xml.contact.Activity[1];
    crmondemand.xml.contact.Activity activity = new crmondemand.xml.contact.Activity();
    activity.setSubject("");
    activity.setType("");
    activity.setRowStatusOld("");
    activities[0] = activity;
    contact.setContactLastName("='Lee'");
    contact.setContactFirstName("");
    contact.setContactId("");
    contact.setListOfActivity(activities);
    contacts[0] = contact;
    contactlist.setPageSize("10");
    contactlist.setUseChildAnd("false");
    contactlist.setStartRowNum("0");
    contactlist.setListOfContact(contacts);
    System.out.println("contactlist =" +contactlist);
    System.out.println("==1==");
    outlist = stub.contactQueryPage(contactlist);
    System.out.println("==2==");
    crmondemand.xml.contact.Contact[] results =
    new crmondemand.xml.contact.Contact[1];
    results = outlist.getListOfContact();
    crmondemand.xml.contact.Activity[] activitiesout =
    new crmondemand.xml.contact.Activity[1];
    int lenC = results.length;
    if (lenC > 0) {
    for (int i = 0; i < lenC; i++) {
    System.out.println(results.getContactFirstName());
    System.out.println(results[i].getContactLastName());
    System.out.println(results[i].getContactId());
    int lenA = results[i].getListOfActivity().length;
    if (lenA > 0) {
    for (int j = 0; j < lenA; j++) {
    activitiesout = results[i].getListOfActivity();
    System.out.println(" " + activitiesout[j].getSubject() + ", " + activitiesout[j].getType());
    crmod.logoff("https://secure-ausomxdsa.crmondemand.com/Services/Integration", jsessionid_full);
    System.out.println("Loggin Out");
    catch (Exception e)
    System.out.println(e);
    private static String logon(String wsLocation, String userName, String password) {
    String sessionString = "FAIL";
    try {
    // create an HTTPS connection to the On Demand webservices
    URL wsURL = new URL(wsLocation + "?command=login");
    HttpURLConnection wsConnection = (HttpURLConnection)wsURL.openConnection();
    // we don't want any caching to occur
    wsConnection.setUseCaches(false);
    // we want to send data to the server
    // wsConnection.setDoOutput(true);
    // set some http headers to indicate the username and passwod we are using to logon
    wsConnection.setRequestProperty("UserName", userName);
    wsConnection.setRequestProperty("Password", password);
    wsConnection.setRequestMethod("GET");
    // see if we got a successful response
    if (wsConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
    // get the session id from the cookie setting
    sessionString = getCookieFromHeaders(wsConnection);
    } catch (Exception e) {
    System.out.println("Logon Exception generated :: " + e);
    return sessionString;
    * log off an existing web services session, using the sessionCookie information
    * to indicate to the server which session we are logging off of
    * @param wsLocation - location of web services provider
    * @param sessCookie - cookie string that indicates our sessionId with the WS provider
    private static void logoff(String wsLocation, String sessionCookie) {
    try {
    // create an HTTPS connection to the On Demand webservices
    URL wsURL = new URL(wsLocation + "?command=logoff");
    HttpURLConnection wsConnection = (HttpURLConnection)wsURL.openConnection();
    // we don't want any caching to occur
    wsConnection.setUseCaches(false);
    // let it know which session we're logging off of
    wsConnection.setRequestProperty("Cookie", sessionCookie);
    wsConnection.setRequestMethod("GET");
    // see if we got a successful response
    if (wsConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
    // if you care that a logoff was successful, do that code here
    // showResponseHttpHeaders(wsConnection);
    } catch (Exception e) {
    System.out.println("Logoff Exception generated :: " + e);
    * given a successful logon response, extract the session cookie information
    * from the response HTTP headers
    * @param wsConnection successfully connected connection to On Demand web services
    * @return the session cookie string from the On Demand WS session or FAIL if not
    found*
    private static String getCookieFromHeaders(HttpURLConnection wsConnection) {
    // debug code - display all the returned headers
    String headerName;
    String headerValue = "FAIL";
    for (int i = 0; ; i++) {
    headerName = wsConnection.getHeaderFieldKey(i);
    if (headerName != null && headerName.equals("Set-Cookie")) {
    // found the Set-Cookie header (code assumes only one cookie is being set)
    headerValue = wsConnection.getHeaderField(i);
    break;
    // return the header value (FAIL string for not found)
    return headerValue;
    private static String getSessionId(String cookie) {
    StringTokenizer st = new StringTokenizer(cookie, ";");
    String jsessionid = st.nextToken();
    st = new StringTokenizer(jsessionid, "=");
    st.nextToken();
    return st.nextToken();
    this source excute, print this error message.
    Loggin In
    281e56bb61372daba8c0a7db2d85d403536cf7645ee1247f527466c281cf1f30.e34QbhuQbNqSci0LbhiKaheTaNyKe0
    - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
    contactlist =crmondemand.ws.contact.ContactWS_ContactQueryPage_Input@702c65ba
    ==1==
    java.net.ConnectException: Connection refused: connect
    Process exited with exit code 0.
    i found many internet homepage, but i can't solve this problem.
    help me~~~ T.T
    p.s: I set My host file -> 127.0.0.1 some-proxy.com
    JDeveloper version = 11g Release 2
    OS = windows XP

    It looks like you have some problems that aren't CRMOD related.
    If you have the XML you are building and can post here that would help as well.

  • How to use the substring and can i class method for the primitive type

    MY COMPILER
    public class StringLine
    public static void main(String[] args)
    String sentence;
    char letter;
    char name;
    int position;
    System.out.println("Enter a line of text. No punctuation please");
    sentence = MyIO.readLine();
    System.out.println("I have rephrase that line to read:");
    position = sentence.indexOf(" ");
    name = sentence.charAt(postion, position+ 1);
    name = name.toUpperCase();
    letter = sentence.charAt(0);
    letter = letter.toLowerCase();
    sentence = name + sentence.substring(position + 2)
              + letter + sentence.substring(1, position);
    //////////////// I got 3 errors following:
    StringLine.java:16: cannot resolve symbol
    symbol : variable postion
    location: class StringLine
    name = sentence.charAt(postion, position+ 1);
    ^
    StringLine.java:17: char cannot be dereferenced
    name = name.toUpperCase();
    ^
    StringLine.java:20: char cannot be dereferenced
    letter = letter.toLowerCase();
    ^
    3 errors
    }

    position = sentence.indexOf(" ");
    name = sentence.charAt(postion, position+ 1);
    name = name.toUpperCase(); two error here:
    1. as stated above postion is mispelled...should be position
    2. you cannot perform a chatAT(int, int)
    I think you want to perform a substring
    String name;  // should be a string instead of a char..(char is a primitive and all primitive have no method)
    position = sentence.indexOf(" ");  
    name = sentence.substring(position, position + 1).toUpperCase();
    [./code]
    better yet..you should check if the sentence does contain a spaceString name;
    position = sentence.indexOf(" "); // return a negative value if the search string is not part of the string
    if (position != -1)
    name = sentence.substring(position, position + 1).toUpperCase();
    else
    System.out.println("The sentence does not contain a space);
    [./code]
    String letter;
    letter = new String(sentence.charAt(0));
    letter = letter.toLowerCase();
    // or
    char letter;
    letter = sentence.toLowercase().charAt(0);

  • "requires unreachable" warning emitted when using static variables and the singleton pattern

    I'm implementing code contracts on an existing code base and I've come across this situation in a few places. Wherever we have additional logic with code contracts where a singleton instance is instantiated, all code contracts emit a "reference use
    unreached", or "requires unreachable" warning.
    The code below demonstrates this.
    static string instance = null;
    static string InstanceGetter()
    if (instance == null)
    instance = "initialized";
    AdditionalLogic(instance); // requires unreachable warning on this line
    return instance;
    static void AdditionalLogic(string str)
    Contract.Requires(str != null);
    Console.WriteLine(str);

    Would the class get unloaded even if the Singleton object has some valid/reachable references pointing to it?
    On a different note, will all the objects/instances of a class get destroyed if the class gets unloaded.That's the other way round, really: instances cannot be garbage-collected as long as they are strongly reachable (at least one reference pointing to them), and classes cannot be unloaded as long as such an instance exists.
    To support tschodt's point, see the JVM specifications: http://java.sun.com/docs/books/jvms/second_edition/html/Concepts.doc.html#32202
    *2.17.8 Unloading of Classes and Interfaces*
    A class or interface may be unloaded if and only if its class loader is unreachable. The bootstrap class loader is always reachable; as a result, system classes may never be unloaded.
    Will the same case (Custom ClassLoader getting unloaded) occur if I write the singleton using the code wherein we lazily initialize the Singleton (and actually create a Singleton instance rather than it being a Class/static variable).You should check the meaning of this vocabulary ("object", "instance", "reference"): http://download.oracle.com/javase/tutorial/java/javaOO/summaryclasses.html
    The difference between the lazy vs eager initializations is the time when an instance is created. Once it is created, it will not be garbage collected as long as it is reachable.
    Now I'm wondering, whether being referenced by a static attribute of a class guarantees being reachabe. I'm afraid not (see the JLS definition of reachable: http://java.sun.com/docs/books/jls/third_edition/html/execution.html#44762). That is, again, unless the class has been loaded by the system class loader.

  • Receiver Determination and Interface Determination Condition conflict in ICO

    Hi,
    I found a strange issue today while configuring two receivers using the Receiver and Interface Determination conditions.
    Sender - Proxy Service
    Receiver1 - ReceiverA
    Receiver2 - ReceiverB
    Receiver Determination Condition : When Field1 = 100, message should flow to ReceiverA and ReceiverB
    Interface Determination Condition (ReceiverA) : When Field1=100 and Field2=50 message should flow to a specific interface in ReceiverA
    There is no Interface Determination condition for ReceiverB, for all messages having Field1=100, it should go to ReceiverB.
    Test Scenarios:
    1) Field1=100, Field2=50 : Message flows successfully to ReceiverA and ReceiverB
    2) Field1=100, Field2=89 : Message fails to process from ECC itself throwing Interface Determination not found error. Ideally this is a positive scenario for ReceiverB and it should send the message to ReceiverB without any errors. But, this did not happen in this case
    I tried the same by configuring the conditions completely in Receiver Determination itself without using the Interface Determination, it worked perfectly fine. But, just wanted to understand that if this is an expected behavior.

    Hi Sherin,
    As there are two receivers Receiver A and Receiver B.You need to create two bussiness components and two communcication channels for two receivers and one Reciver Determination, two Interface Determination,two Receiver Agreement.In Receiver Determination you need to keep the below and condition.
    In the above screenshot the two receiver are Receiver B and Receiver C and Field 1 is Key_Value and Field2 is Emp_ID.
    If the Key_Value=100 and Emp_ID =22 then the message should go to both the receivers B & C by keeping the following AND condition
    If the Key_Value=100 and Emp_ID is not equal to 22 then the message should go only to Receiver B by keeping the following condition
    You need not keep any condition in Interface Determination just create 2 Interface determination for two receivers.
    Hope this helps you.
    Thanks,
    Durga.

  • When to use interface and when Abstract Class?

    In a recent interview I was asked "When to use interface and when Abstract Class?" Explain with an example.
    Also in what situations a class should be made final(real time example)

    Interface is a pure contract with no implementation. Typically used to define a communication contract between two different sub-systems. Example EJB home interface. This also allows the design to change as long as the contract is met.
    Abstract class is when there exists a lot of common functionality already known and can be coded. However, a few unknowns exists (typically about data) for which abstract methods need to be defined and implemented by the sub class.
    Example: Consider a workflow engine. A great example for abstract class. The workflow process has lot of common code that is independent of the workflow type (vendor flow, contract flow, payment flow etc). However, certain decisions on the route to take will depend on value of data being submitted. So the base class will define a abstract Data getData() method and proceed assuming data will come. The implementing subclass will provide the actual logic for getting the data.
    Also see the "Template" design pattern.
    Note: To some extent the common code design drives the behavior of the abstract methods. So if the design changes then so "might" the behavior expected from the abstract methods.

  • What happens as we use strictfp modifier with class and interface ?

    I just knew that strictfp can't be used with variables?
    I want to know that why we use strictfp with class and interface?

    makpandian wrote:
    i hope i can understand if you explain myself.Okay, let me go ahead and try to explain yourself.
    The concept of a makpandian can be summed up as the following: a simple-minded, java forum-goer who posts questions directly from his SCJP 6 study guide in hopes that forum members will give him a simple answer that he can correlate to a multiple-choice response. By doing this, the makpandian suspects that passing the SCJP 6 exam will become a tangible reality, thus enabling it to obtain a job in the public work sector (given the great significance of this type of certification in the makpandian's presumed country of origin (India, for those of you who aren't following along)).
    So how'd I do? Did I do a good job of explaining yourself?

  • Differences between Robot class generated events and real input events

    Hello everyone!
    I'm having a problem with the translation of the description of the awt.Robot class.
    - "This class is used to generate native system input events" -
    Does this mean there is no difference between real input events and generated events from the Robot class? Difference in reference to that the generated events can't be recognized as generated events by the os or programs.
    Thanks in advance.
    Chris B.

    The Robot class will use an interface provided by the operating system to inject events. Those are very close to 'real' input events, but not quite there. There are, for instance, several games out there which have a protection mechanism against Robot's events to prevent scripting/botting. However, any application that is not paying special attention to the event's source will assume that the input events generated by Robot are actually coming from the user, so you can 'control' any application with the exception of the beforementioned games.

Maybe you are looking for

  • XML Publisher error..urgent

    Hi all, I am new to XML Publisher.I have tried to publish a Oracle Report in EBS with XML publisher, but failed. I defined the data definition and the Template as said in the UserGuide.Then i set up the report (in the Concurrent..Program..Define wind

  • Is there a way to open an iphoto 9 with a iphoto library that was saved in iphoto 11?

    I recently reformatted my hard drive which had iPhoto 11 on it.  I backed up the iphoto library by copying it to an external hard drive. I re installed Snow Leopard on my Macbook and do not want to re install iPhoto 11 or Mountain Lion as my Macbook

  • How do I upgrade FCPX to an older version

    The lastest downgrade of FCPX has totally ruined the synchhronization of mullticam clips. Is there any way to get the older version back?

  • Help with Dreamweaver type

    I have created 2 webpages. One uses CSS and the other does not. The one without CSS ( http://www.mostlykidsinc.com) has type that looks smaller in Safari than in Firefox and IE. I thought that if I use CSS ( http://www.mostlykidsinc.com/test) then th

  • Recognising scanner in Photoshop

    Does anyone know how to set up Photoshop CS4 so that it recognises my Canon LIDE100 scanner, so that I can connect to the scanner from within Photoshop? Grateful for any advice on this Peter de Wit