Synchronous User Interaction in Instance-Method

Hey Guys!
I got a problem getting information by user synchronous.
To make it understandable I abstracted the problem a little:
I have a class 'player'. It has an attribute 'name' and a method 'get_name'.
In get_name i want to ask the actual user for his/her name. A dialogue should open with a text-field and an ok-button.
(Solvable with DD_Documents -> no Problem as far).
But then I want to save the given value in text-field in the 'name'-variable.
This is a problem: Not because of getting the  data out of the input field but because of the flow-control!
I know I could write a method in the same class to react to the interaction and save the variable. But if I want to use one or more players in a program, it does not wait until the variable is set to go on.
I do not want to go on with the code in the method as long as the user didn't press ok.
Can I wait for an event in a method?
Hope you get my problem!
Thank you for your help!

Hi Wolfgang,
I would try this kind of approach and see if it will solve your problem (I'm assuming your EVENTS are raised in the method display_document):
First, I would cut the following lines from the method ask_for_name:
  set handler dbox_close for all instances.
  set handler dd_btn_clicked for all instances.
  set handler dd_ie_entered for all instances.
Second, I would add this DEFINITION of a local class & object declaration (I guessed on parameter & class names):
** Local class definition for event receiver
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
    handle_dbox_close
      FOR EVENT dbox_close OF zcl_player_class
        IMPORTING e_name,
    handle_dd_btn_clicked
      FOR EVENT dd_btn_clicked OF zcl_player_class
        IMPORTING e_name,
    handle_dd_ie_entered
      FOR EVENT dd_ie_entered OF zcl_player_class
        IMPORTING e_name.
ENDCLASS.                    "lcl_event_receiver DEFINITION
DATA: g_event_receiver TYPE REF TO lcl_event_receiver.
Third, I would make the following changes in your main method:
method main.
  CREATE OBJECT g_event_receiver
  create object s1.
  create object s2.
  create object s3.
  SET HANDLER g_event_receiver->handle_dbox_close FOR ALL INSTANCES.
  SET HANDLER g_event_receiver->handle_dd_btn_clicked FOR ALL INSTANCES.
  SET HANDLER g_event_receiver->handle_dd_ie_entered FOR ALL INSTANCES.
  s1->ask_for_name( ).
  s2->ask_for_name( ).
  s3->ask_for_name( ).
write:/ s1->name.
write:/ s2->name.
write:/ s3->name.
endmethod.
And lastly, insert the implementation for each of the handler methods:
*&       Class (Implementation)  lcl_event_receiver
*        Event receiver for player class
*       CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_dbox_close.
  ENDMETHOD.
  METHOD handle_dd_btn_clicked.
  ENDMETHOD.
  METHOD handle_dd_ie_entered.
  ENDMETHOD.
ENDCLASS.               "lcl_event_receiver
Regards,
Ryan Crosby
Edited by: Ryan Crosby on Nov 8, 2011 9:50 AM

Similar Messages

  • Synchronous User Interaction in Method

    Sorry: Wrong forum!
    Edited by: Wolfgang Dörner on Nov 4, 2011 2:03 PM

    Sorry: Wrong forum!
    Edited by: Wolfgang Dörner on Nov 4, 2011 2:03 PM

  • Synchronized Instance Methods in Singleton Class

    If I've a TransactionManager class that's a singleton; meaning one manager handling clients' transaction requests, do I need to synchronize all of the instance methods within that singleton class?
    My understanding is that I should; otherwise, there's a chance of data corruption when one thread tries to update, but another thread tries to delete the same record at the same time.

    Let's say that you have a singleton that is handling
    the printing in a desktop application. This could be
    time consuming and it will not probably be used too
    often. What's time consuming about instantiating the object?
    On the other hand you could not say that it
    will never be used.Exactly. If that were so, why write it?
    In a web application, response time is much more
    important than initialization time (which can be
    easily ignored). Never ignored. It's just a question of when you want to pay.
    Web app as opposed to desktop app? Does response time not matter for them?
    In this case, of course, eager
    initialization makes much more sense.I'm arguing that eager initialization always makes more sense. Lazy for singletons ought to be the exception, not the norm.
    %

  • Should I use a static method or an instance method?

    Just a simple function to look at a HashMap and tell how many non-null entries.
    This will be common code that will run on a multi-threaded weblogic app server and potentially serve many apps running at once.
    Does this have to be an instance method? Or is it perfectly fine to use a static method?
    public static int countNonNullEntries(HashMap hm){
    if(hm==null)return 0;
    int count=0;
    for(int i=0; i<hm.size(); i++) {
    if(hm.get(i)!=null)
    { count++;}
    return count;
    OR
    public int countNonNullEntries(HashMap hm){
    if(hm==null)return 0;
    int count=0;
    for(int i=0; i<hm.size(); i++) {
    if(hm.get(i)!=null)
    { count++;}
    return count;
    }

    TPD Opitz-Consulting com wrote:
    The question is the other way around: Is there a good reason to make the method static?
    Ususally the answer is: no.The question is: does this method need state? Yes -> method of a class with that state. No -> static.
    The good thing of having this method statig is that it meight decrese memory foot pring but unless you're facing memory related problem you should not think about that.I doubt there is any difference between the memory foot print of a static or not method.
    I'm not shure if this method beeing static maks problems in multithreaded environments like the one you're aiming at. But I do know that an immutable object is always thread save.Does the method use shared state (data)? No -> no multi threaded problems.
    Can the parameters be modified by different threads? Yes, if multiple threads modified the parameter map, but nothing you can do about it here (no way to force the calling thread to lock on whatever you lock on).
    So my answer to your question is: yes, it should be non static.The method should be static since it uses no state.
    It is thread-safe when only the calling thread can modify the passed map (using a synchronized or ConcurrentHashMap is not enough, since you don't call a single atomic method on the map).
    // Better use Map instead of HashMap
    // We don't care about the generic type, but that does not mean we should use a raw type
    public static int countNonNullEntries(Map<?, ?> map) {
      // whether to accept null map or not, no need for explicit exception
      // since next statement throw NPE anyway
      Collection<?> values = map.values();
      // note your method is called countNonNull, not countNull!
      // (original code it would need to by if(null != mapValue) notNullsCounter++;
      return values.size() - java.util.Collections.frequency(values, null);
    }

  • File Download Without User Interaction

    Hello,
    basically i want to transfer a file from one server to the
    other. I have a fixed source URL and a ready file handler .jsp at
    the destination server.
    In the past I did a lot with FileReference and their Browse()
    and Download() methods. Now i want to replace those points of user
    interaction and more or less stream the download file into the
    upload handler. Any ideas how i could achieve that?
    Thanks and GzG
    Nerun

    http://forum.java.sun.com/thread.jspa?messageID=3578246&#3578246
    Common sence would have told you that a <input type=file ... cannot be set with script.
    Since this input can be set to hidden you might unwantingly submit files on every page
    you visit.

  • How can I use instance methods created with HashMap

    class Template
    static HashMap customer;
    a few methods created various customer
    public static display() //to display a particular customer information among i've created above
                 String objectName,currentObjectName;
              Customer customer;
              Scanner scan=new Scanner(System.in);
              System.out.print("Please enter the customer name");
              objectName=scan.nextLine();
              Iterator iteratorForCustomer=CustomerMap.entrySet().iterator();
              Map.Entry customerEntry=(Map.Entry)iteratorForCustomer.next();
             while(iteratorForCustomer.hasNext())
                    customerEntry=(Map.Entry)iteratorForCustomer.next();
                    if(objectName.equals((String)customerEntry.getValue()))
              System.out.println("Name : " +customer.getName()); //I'm trying to reference to an instance method getName() here but i can't do that .
    }The problem is I've created as many as I want and later in the program I tried to redisplay a particular customer information based on the input (objectName). User type in the objectName and I tried to look for a particular customer Object in the HashMap and display only the relevant customer information. Is there any way to do it ? Thanks everyone in advance.

    Peter__Lawrey wrote:
    use the get method
    [http://www.google.co.uk/search?q=map+tutorial+java]
    [http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html]
    And then either look at a generics tutorial, or, if you're stuck on a pre-1.5 version of Java, find out about casting

  • Instance methods faster than sync. static methods in threaded env?

    consider the following please:
    (-) i have "lots" of instances of a single Runnable class running concurrently..
    (-) each instance uses a common method: "exponential smoothing" and they do a lot of smoothing.
    so:
    (option #1): include a "smooth()" instance method in the Runnable class.
    (option #2): include a "smooth()" synchronized static method in the Runnable class.
    (option #3): create a MathUtility class, and have "smooth()" as an instance method in this class.
    (option #4): make "smooth()" a synchronized static method in the MathUtility class.
    from OOP point of view, i think i should externalize "smooth()" to a MathUtility class, and then make
    is "synchronized static".
    but then from a performance point of view....
    would not it be optimal to make "smooth()" an instance method in MathUtility and then have each
    instance of the Runnable create its own MathUtility instance so that each thread has its own copy
    of the "smooth()" method??
    well, i can't image there would be a measurable difference so maybe i should not post.
    but, if there is a flaw in my thinking, please let me know.
    thanks.

    kogose wrote:
    from OOP point of view, i think i should externalize "smooth()" to a MathUtility class, and then make
    is "synchronized static".From an OOP point of view you should probably have a class that represents the data that provides a (non-static) smooth() method that either modifies the data or returns a new smoothed data object (depending on whether you want your data objects to be immutable or not).
    but then from a performance point of view....
    would not it be optimal to make "smooth()" an instance method in MathUtility and then have each
    instance of the Runnable create its own MathUtility instance so that each thread has its own copy
    of the "smooth()" method??No, methods are not "copied" for each instance. That just doesn't happen.
    well, i can't image there would be a measurable difference so maybe i should not post.If you don't know, then you should probably try it.
    but, if there is a flaw in my thinking, please let me know.The flaw in your thinking is that you can think that you can intuitively grasp the difference in performance of a change at that level.
    I have yet to meet anyone who can reliably do that.
    Performance optimization is not an intuitive task at that level and you should never do performance optimizations without proving that they are improvements for your particular use case.
    First part: Is the smooth() method really thread-unsafe? Does it use some shared state? My guess would be that it uses only local state and therefore doesn't need any synchronization at all. That would also be the fastest alternative, most likely.

  • Any way to Upload a File Automatically without user interaction in BSP.

    Hi,
    Any way to Upload a File Automatically without user interaction in BSP.
    Problem is;
    We have an terminal pc connected to an Production Machine and has a PLC for reading Machine Actual Datas. This terminal has Windows CE.NET OS. There is one program which Appending PLC Data to Text file (STORAGE CARD\PLC\SAMPLE.TXT).
    Users can access to WAS system in this Terminal (Has network).
    I have to access to SAMPLE.TXT file using BSP when user antered a page in WAS.
    Have you got any solution. I have tried so much methods to do this. But i have not found any solution.

    Yes SAMPLE.txt stored in "STORAGE CARD\PLC" folder in terminal.
    But i am trying in my computer to test with "C:
    GPS.txt"
    I have tried before this method. But I think this is a security exception. Because when i use
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    extName = fso.GetExtensionName("C:\GPS.txt");
    alert(extName)
    -->
    </SCRIPT>
    i am getting an alert with message "txt". there is no problem.
    But when i try to access file using this code
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    fileObj = fso.GetFile("C:\GPS.txt");
    -->
    </SCRIPT>
    i am getting "Automation server can't create object".
    Message was edited by:
            Ibrahim UGUR

  • Dialog with no user interaction

    Hi all,
    I would like to use the one button dialog that would just showing a message without requiring any user interaction.  With the dialog, I only want to display a message for the user. I want the program to continue running without needing user interaction.  I just want to let the user know that something happened.  I don't need to user to do anything.  How do I do that? 
    Yik
    Kudos and Accepted as Solution are welcome!
    Solved!
    Go to Solution.

    A more common approach is to use a "Status log" (just a string on the UI that gives the user some idea what is going on.)
    Here is a construct I often use (place the control "Status" on the UI, Add a control to the referance to "Status" wire the Connector pane.)  This type of action engine (see Ben's excellant nugget) lets you send update messages to the user from anywhere in the application instance space without leaving pop-ups all over the screen.
    And should you wish, you can add cases to Show, blink, unblink, highlight, move or Hide the indicator so it peeks out and dances
    Jeff

  • Objects and instance methods for JSP?

    I've been looking through the JSP 2.0 specification and, while I'm extremely impressed with the improvements in this version, I'm also disappointed to see that everything still boils down to statically bound methods.
    What I mean by this is that the template part of a JSP is like an anonomously named static method associated with the JSP class. The new tag-files in JSP 2.0 are terrific, but they also have this same kind of static binding.
    As far as I know, only JPlates (www.jplates.com) allows you to develop web applications using actual instances of classes that have instance methods for expressing the template parts. Are there any other template processing systems that support real object-oriented development of dynamic content-generation applications?

    By an amazing coincidence, the domain name jplates.com is registered to a Daniel Jacobs and your user name is djacobs. What are the odds of that?
    If you're going to plant commercials, you need to disguise them better than this.

  • (sqr 2515) input required user interaction but user interaction was disabled by the -XI command line

    hi ,
    i'm getting below while running sqr in 3-tier mode using process scheduler.
    (sqr 2515) input required user interaction but user interaction was disabled by the -XI command line
    can any one suggest me to resolve this problem

    You should be able to get some more precise information from your Xorg logs, but I would bet it is related to the evdev driver. Some of the options in your xorg.conf no longer work with the latest version. For now you should be able to either map your mouse directly to the appropriate /dev/event* entry or change to the standard mouse driver, both of those methods should be in the wiki.
    You are supposed to be able to use the evdev driver without the input section of your xorg.conf by using dbus/hal autodetection, but AFAIK at the moment the xorg-server package still isn't compiled with hal support, so you would have to patch and rebuild the package.

  • Whats the difference between a class method and a instance method.

    I have a quiz pretty soon and one of the questions will be: "How does an instance method differ from a class method." I've tried looking this up but they gave me really complicated explanations. I know what a instance method is but not really sure what a class one is. Can someone post an example of a class method and try to explain what makes it so special?
    Edited by: tetris on Jan 30, 2008 10:45 PM

    Just have a look:
    http://forum.java.sun.com/thread.jspa?threadID=603042&messageID=3246191

  • How to call a instance method without creating the instance of a class

    class ...EXCH_PRD_VERT_NN_MODEL definition
    public section.
      methods CONSTRUCTOR
        importing
          value(I_ALV_RECORDS) type ..../EXCH_VBEL_TT_ALV
          value(I_HEADER) type EDIDC .
      methods QUERY
        importing
          I_IDEX type FLAG
          i_..........
        returning
          value(R_RESULTS) type .../EXCH_VBEL_TT_ALV .
    Both methods are instance methods.
    But in my program i cannot created instance of the class unless i get the results from Query.
    I proposed that Query must be static, and once we get results we can create object of the class by pasing the result table which we get from method query.
    But i must not change the method Query to a static method.
    Is there any way out other than making method Query as static ?
    Regards.

    You can't execute any instance method without creating instance of the class.
    In your scenario, if you don't want to process your method of your class, you can check the instance has been created or not.
    Like:
    IF IT_QUERY IS NOT INITIAL.
      CRATE OBJECT O_QUERY EXPORTING......
    ENDIF.
    IF O_QUERY IS NOT INITIAL.
    CALL METHOD O_QUERY->QUERY EXPORTING....
    ENDIF.
    Regards,
    Naimesh Patel

  • Error in Installation of Aqualogic User Interaction 6.5

    Hi,
    I have installed Aqualogic User Interaction 6.5, with Weblogic 9.2, Apache 2.0.63, Oracle 10g.
    Portal Diagnostic is running successfully.
    But while i am trying to start the weblogic server it is throwing me the following error-
    Task 'InitPortalObjects' failed on startup
    Task #1 <InitPortalObjects) Step#3
    OpenKernal Initialization Failure(Java)
    Recommendation:Review the detailed exception listed below for specific analysis. Check that pthome.xml is in the correct place,check that the PT_HOME environment variables points to it, and check that your database settings by runing ptconfig. Check that your database settings by running ptconfig. check that the portalconfig.xml file is accessible by the web application server.
    My pthome is in the correct place, also the PT_HOME is pointing at the correct place.
    Also the weblogic is pointing to the other machine. Is this the reason for the above error?
    Thanks in Advance!

    Hi Patel,
                         Thanks for your update.
    Regards,
    Hari.

  • Which is better?    Two Oracle user in one instance OR  in two instances?

    Which is better?
    I could not find any benchmark for number of instances per user
    in the same machine.
    suppose that you have two major Oracle user, from performance
    point of view it is better to make separate instances in same
    machine or keep these two users in the same instance.

    Hi.
    I understand that you will use oracle for two different
    applications on the same host.
    Each instance has its SGA and background processes. So, using
    two different schemas(users) in one instance you can share
    phisical memory between the applications. Concerning background
    processes, you can start as many of them as you wish, so it's
    not a problem. If you decided that one DBW is not enough, you
    could configure oracle to use two or more.
    best regards,
    Andrew

Maybe you are looking for

  • Would a custome made adobe acrobat plugin work in adobe acrobat X pro and XI pro?

    We are looking to write a c++ pdf compare plugin with adobe acrobat sdk 8, but not sure if the plugin in will work in the latest adobe acrobat XI pro since the sdk is 8.0. Can someone with experience in this area confirm whether the plugin would work

  • How do i get an ios update?, How do i get an ios update?

    Getting an ios update on my ipad is SO FRUSTRATING.  My ipad is connected to the internet but i can't find the system update button on the system settings.  I TRIED EVERYTHING, talking to apple people, looking on websites, using my computer, but the

  • Uploading receipts

    Not uploading receipts properly in org id like 39,1676,192 When we resolve the all errors it showing PENDING status. but receipts uploading properly in org id=38

  • OS open file dialog vs my dialog

    hi, I have problem redirecting main page from dialog. On main page, there is a report link. If this link pressing, an dialog is shown up and user selecting some values to see at pdf report. After selecting value, pressing "get report" button at the d

  • ACE 20 CAS servers

    Hi all, I have to load balance two CAS servers. Is this the correct way to setup the probes and serverfarm. I am using an ACE 20. probe tcp TESTCAS-PROBE   interval 3   passdetect interval 5 parameter-map type ssl SSL-TESTCAS-FARM-ADVANCED   cipher R