Child form calling a method on it's parent's class.

I am developing a form-based application. There is one root
form called "Application" and a few child forms off the root (e.g.,
Login, CustView). I would like the sibling forms to be able to pass
contol to each other (e.g., after successful login, I want to make
Login invisible and CustView visible).
I wanted the root form to control this interaction, but I'm
not sure how events in child can be handled in the parent. This is
a common technique, but in this case, the parent doesn't explicitly
instantiate the child, so I can't just pass a reference to the
parent to the child's constructor. I can use this.parentForm to get
a reference to the parent form, but I can't seem to find the
parent's methods, just it's gui elements (i.e.,
this.parentForm.parentMethod() doesn't work).
Can some tell me how to do this? I am considering a
FormManager class, which is a singleton class that each form can
registers with and can use to toggle the visibility of itself and
its siblings, but I wanted to see if there was an easier way to
access methods on the class instance associated a parent's form.
Any suggestions?
Andy

"agorman" <[email protected]> wrote in
message
news:e2163h$4na$[email protected]..
>I am developing a form-based application. There is one
root form called
> "Application" and a few child forms off the root (e.g.,
Login, CustView).
> I
> would like the sibling forms to be able to pass contol
to each other
> (e.g.,
> after successful login, I want to make Login invisible
and CustView
> visible).
>
> I wanted the root form to control this interaction, but
I'm not sure how
> events in child can be handled in the parent. This is a
common technique,
> but
> in this case, the parent doesn't explicitly instantiate
the child, so I
> can't
> just pass a reference to the parent to the child's
constructor. I can use
> this.parentForm to get a reference to the parent form,
but I can't seem to
> find
> the parent's methods, just it's gui elements (i.e.,
> this.parentForm.parentMethod() doesn't work).
>
> Can some tell me how to do this? I am considering a
FormManager class,
> which
> is a singleton class that each form can registers with
and can use to
> toggle
> the visibility of itself and its siblings, but I wanted
to see if there
> was an
> easier way to access methods on the class instance
associated a parent's
> form.
>
> Any suggestions?
>
Why don't you explicitly instantiate the children with a
reference to the
parent form. That way you could store the reference in the
constructor. As
long at the functions are public I think it should work.
Amy

Similar Messages

  • How to call a method in private section of a class in the public section

    Hi Everybody,
    i have written a method(meth1) in the private section of a class(C1).
    it is as follows
    class C1 definition.
    private section.
    methods: meth1 importing im_dt1 like tp1
                                             im_dt2 like tp2
                                             im_dt3 like tp3
                                             im_dt4 like tp4
                               returning value(re_dt1) like tp5.
    endclass.
    i have the final data that has to be displayed in internal table re_dt1.
    now my question is how to call  this method present in private section into public section and display the data present in re_dt1.
    Thanks,
    learning.abap.

    Hi,
    what you need is one public method being called at start-of-selection. Within this the private methods have to be called.
    The question is, why has the method for reading the database tables to be private? If you have only one private method reading all database tables the public method being called at start-of-selection will only consist of a call-method statement.
    This seems to be one call to much.
    The logic for reading the different database tables is hidden inside the class anyway.
    Is there any further logic reading the different database tables?
    Have always all table to be read? If not another approach would be one private method for each database table being called by a public method deciding which table has to be read:
    public section.
    methods get_data returning value(re_Dt1).
    private section.
    methods:
    get_table_a returning value(im_dt1),
    get_table_b returning value(im_dt2),
    get_table_c returning value(im_dt3),
    get_table_d returning value(im_dt4),
    combine_data importing im_dt1
                                    im_dt2
                                    im_dt3
                                    im_dt4
                            returning value(re_dt1).
    *- implementation of public method:
    method get_data.
      data: lt_dt1 ...
               lt_dt2,
               lt_dt3,
               lt_dt4.
    * here decide which tables have to be read:
    lt_dt1 = get_table_a( ).
    lt_dt2 = get_table_b( ).
    lt_dt3 = get_table_c( ).
    lt_dt4 = get_table_d( ).
    re_dt1 = combine_data( i_dt1 = lt_dt1
                                           i_dt2 = lt_dt2
                                           i_dt3 = lt_dt3
                                           i_dt4 = lt_dt4 ).
    endmethod.
    *- implementation of private methods
    method get_table_a.
    endmethod.
    method get_table_b.
    endmethod.
    method get_table_c.
    endmethod.
    method get_table_d.
    endmethod.
    method combine_data.
    endmethod.
    Regards
    Dirk

  • Calling instance method from an instance of a class.

    Hi,
    Can anyone tell me How can i change this TestAccount0 class so that i get the balance from Account class.
    public class TestAccount0
       public static void main(String[] args) {
         Account.deposit(1000);
         System.out.println(Account.getBalance());
    }I have done it this way. I just want to print the balance without* saving the instance of the Account class in any variable in the 1st statement. Can i do it this way?. I have made instance of Account class to access deposit method but how can i print whatever is in the first statement? What can i do to print 1000 as says in the 1st statement because apparently it is printing balance 0.
    Thanks
    public class TestAccount0
       public static void main(String[] args) {
                 (new Account()).deposit(1000);//make instance of Account class to access the method of Account class.
                 System.out.println((new Account()).getBalance());// prints the balance which in this case would be 1000.
    }

    Jas85 wrote:
    So the original code doesn't read Account.deposit(1000) at all?
    I think you can make that work by writing instance of class I.e (new Account()).deposit(1000).(a) please answer the question
    (b) Not unless you want to throw away the Account, and its balance, immediately. Which doesn't make sense, does it?
    Alternatively the original code doesn't look like that at all ...
    ok...you are saying they have given me the wrong code to fix.No, I am saying that either the original code doesn't look like what you posted here, or they have given you an impossible assignment. It should look like this:
    Account ac = new Account();
    ac.deposit(1000);
    System.out.println("balance="+ac.getBalance());

  • Passing Values to Child Forms

    I have a parent summary form. When the user presses a button, it pops up a detail form for the user to edit/fill in. How do I pass the initial values from the parent form to the child form and back? Where can I find an example of this?

    DeltaGeek wrote:
    BarryC wrote:
    Thank you.
    Do you happen to know of any tutorials/examples showing various methods of passing values between forms?The same way you pass values anywhere else. When you create your child form, give it a reference to the parent form or references to the data that will be changed. If you feel like making your code more modular, create a class specifically to hold the entered data and be passed anywhere you need.An application context, in effect

  • How to call main method in one class from another class

    Suppose i have a code like this
    class Demo
    public static void main(String args[])
    System.out.println("We are in First class");
    class Demo1
    public static void main(String args[])
    System.out.println("We are in second class");
    In the above program how to call main method in demo calss from Demo1 class......???????

    No, i dont know how to call other than main methods from other classes
    And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

  • Error when calling a method inside a form routine...

    Hello experts,
    I am trying to call a method inside a form but it is giving me an error. The error is:
    Access not possible using 'NULL' object reference.
    Anyway, below is my code guys:
    START-OF-SELECTION.
      DATA: main          TYPE REF TO lcl_main,
            old_and_new   TYPE REF TO lcl_old_and_new,
            check_changes TYPE REF TO lcl_check_changes,
            messages      TYPE REF TO lcl_messages.
      CREATE OBJECT: main, old_and_new, check_changes, messages.
          FORM get_orig_contents_of_zts0001                             *
    FORM get_orig_contents_of_zts0001.
      CALL METHOD main->export_old_recs.
    ENDFORM.
    Help would be greatly appreciated. Thanks a lot and take care!

    Before the "START-OF-SELECTION " just add this sentense :
    <b>class lcl_main definition deferred.</b>
    CLASS Definition.
    ENDCLASS.
    CLASS Implementation.
    ENDCLASS.
    START-OF-SELECTION.
    *Do your coding here
    <b>in this way we are deferring the class definition for later</b>

  • Calling  dll method from oracle forms

    Hi,
    This is my first post in this forum. I don't know whether this is the right place to post this topic here.
    i wana call DLL method from the button click event of my form.
    I new to oracle development any help will be greatly appreciated.

    Calling DLL using form 6i
    Regards,

  • Help with child forms

    Hi,
    I am trying something very simple to learn how child forms work but was not very successful so far. I am hoping one of the experts on this forum can shed some light on what I am doing wrong.
    I did the following:
    1) Created a simple Resource Object.
    2) Created 2 process forms with one of them designated as a child to the other one.
    3) Created a simple Process Task Adapter which simply prints the assigned variables data out to STDOUT
    4) Created a Process Definition and added a task called Create User and used the adapter created in previous step.
    5) In the integration tab, I did the mapping of both the parent and child form data to the adapter variables.
    Whenever I assign the RO to an user, I keep getting the following error.
    When ever I go and assign the RO to the user
    19:05:17,014 ERROR [DATABASE] select UD_RO3_CF_ATTR1 from UD_RO3_CF where UD_RO3_CF_KEY =
    java.sql.SQLException: ORA-00936: missing expression
    I also tried the following. In the general tab, from the child table drop down, I selected the child form name and for trigger type, selected insert. When I do that, I get the following error..
    In browser, I get
    DOBJ.GEN_ERROR
    Cannot schedule a task for child table change, schedule item save failed
    In the logs, I see the following exception..
    12:35:57,718 INFO [DATABASE] Class/Method: tcDataBase/setTransaction: ##########setTransaction getting called from: #######
    12:35:57,733 ERROR [APIS] Class/Method: tcFormInstanceOperationsBean/addProcessFormChildData encounter some problems: maoErrors:Cannot schedule a task for child table change, schedule item save failed
    12:35:57,749 ERROR [APIS] Class/Method: tcFormInstanceOperationsBean/addProcessFormChildData encounter some problems: Error occurred while validating password policy '
    12:35:57,749 ERROR [APIS] Class/Method: tcFormInstanceOperationsBean/addProcessFormChildData encounter some problems: Cannot schedule a task for child table change, schedule item save failed
    Thor.API.Exceptions.tcAPIException: Cannot schedule a task for child table change, schedule item save failed
    at com.thortech.xl.ejb.beansimpl.tcFormInstanceOperationsBean.addProcessFormChildData(Unknown Source)
    at com.thortech.xl.ejb.beansimpl.tcFormInstanceOperationsBean.addProcessFormChildData(Unknown Source)
    at com.thortech.xl.ejb.beans.tcFormInstanceOperationsSession.addProcessFormChildData(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    Thank you very much

    The details of a child table entry are available only when you define the process task as a child task trigger. You can define the task to trigger based on insert, update, or delete from child table. There is a drop down on the process task configuration screen. When the trigger happens on the child table entry, this is where you can map the value of the child table entry.
    You would want to configure your provisioning process definition to have 1 task for create user, and another task for adding an entry to the child table, and another entry for deleting an entry from the child table. On the delete, you'll want to check the "Old Value" checkbox for the child table mapping.
    -Kevin

  • Read table data from Adobe Form in WD method

    Hello,
       Context is like this :
       ADOBE_DATA        --- Node
             POS                  -
    Node   which has Dict. Stru : TABLE  card : o..n
                   POSNR       --- Attribute
                   MATNR       -
    Attribute
    Created Adobe Interactive Form through the template source of view layout.So xml schema generated automatically
    and is all ok.
    Method on action Submit :
    DATA :
    Node_zatodv_pos       type ref to If_Wd_Context_Node,
    it_zatodv_pos TYPE STANDARD TABLE OF zatodv_tab_pos.
    Node_pos =
                 Node_Adobe_data->get_Child_Node( Name = If_MAIN=>wdctx_POS ).
      Node_pos->get_static_attributes_table( importing table = it_zatodv_pos ).
    When I test the application,this method returns SY-SUBRC is 0 but internal table is "always empty".
    I have also individual attributes in the context which are read correctly.Only get_static_attribute_table doesn't read the table content.Please could any one help me where would be the problem.
    Thank you

    Hi peter,
    If you are trying to add data to a standard SAP table then you should use a FM or BAPI for that but if the table is not standard then you can use following steps but it would be better to do it using FM or BAPI.
    Do the following(without FM/BAPI):
    1. Crate a context in your view mapped to the fields of the database table.
    2. Now use this context as the data source for the form.
    3. Map the fields of the form with the attributes of the context.
    4. Now create a button on the form or on your view which has a action event handler method.
    5. In the method use code wizard to read the context attached to adobe form. By default it will create a structure containing data, which will be sufficient for adding one record at a time.
    6. Now use this structure to add data to table using SQL queries.
    Do the following for FM/BAPI integration:
    1. Create a FM/BAPI which has the functionality to add data to your SAP table.
    2. Now use service call to add the FM/BAPI fields as a context to your web dynpro component's context.
    3. Now map it with the view where the adobe form is created.
    4. Follow steps 2nd, 3rd and 4th as above.
    5. Now in your Action method use code wizard to call the method created by service call to FM/BAPI.
    This will work as required.
    Please reward points if useful.
    Regards,
    Vaibhav Tiwari.

  • How to call a method in backing bean on hitting 'Enter' key on a page.

    Hi all,
    I would be obliged if any one can provide me solution for the below given problem.
    My requirement is to call a method in backing bean when i hit 'Enter' key on a JSP page.
    I am trying this by using a script given below.
    *function fnChangeFocus(){*
    *if(window.event.keyCode==13){*
    * document.getElementById("mainform:submitForm:commandbutton").focus();*
    The JSP has the textbox as given below.
    *<h:inputText id="inputtxtboxid" disabled="false" value="#{Bean.inputvalue}"*
    onkeypress="fnChangeFocus()" size="24" />
    Using this I could not acheive the required functionality. Please suggest some alternative.
    Thanks,
    Jagadeesh Pala

    Only a form element supports the submit() function. Make sure that the getElementById returns the appropriate form. Or rather pass the element as the 'this' reference to the function and get the parent form from it.
    After all this is just basic DHTML / Javascript+DOM knowledge and in fact this has nothing to do with JSF. For future basic DHTML / JS+DOM questions you may take a look at the appropriate forums, e.g. dhtmlcentral.com, dynamicdrive.com, etcetera.

  • Calling a method with a html Submit button

    hi guys,
    is it possible to call a method from a JSP file using a HTML submit button. I know i can call another website easily doing it this way, is there a similar way available to call a method once the button is clicked?
    FYI
    The method is in a bean file named jdbc. The methods name is getUsername.
    Nice one.
    <form action = <%jdbc.getUsername()%> <input type="submit" value="Submit">

    Dear friend,
    you mentioned that u need to call a method when submit button is clicked. Is the method dynamically created. If not so, then you can include the method on the submit button html file itself.
    Regards,
    Rengaraj.R

  • Calling a method in the view controller from the component controller

    Hi
    Is there anyway to call a method in the view implementation from the component controller??
    Thanks
    jack

    Thanks for all your replies. I want this kind of a functionality because Im trying to invove a DC (Child DC) from a Parent DC such that the Child DC's view is displayed onto the view container of the Parent DC. I have embedded using 'interface view of a component instance' in the Parent Window and am able to create the component and set usage though the onPlugDefault of the Child View.
    But I observe that when i make a call from the parent, the flow is like this:
    1. The wdDoInit of the Child Component Controller gets triggered first.
    2. Then the wdDoInit of the Child's <b>VIEW</b> gets triggered
    3. and <b>THEN</b> the onPlugDefault of the Child Component Interface View
    What I had actually wanted was to Fire onPlugDefault where Im calling a method LoadData(), after which the Child DC's view must be triggered so it can display the fetched data.
    What is actually happening is the view gets displayed, but no data is displayed in the view.
    Right now I have just given a work around where Im triggering <b>LoadData()</b> of the <b>COmponent COntroller</b> from the <b>wdDoInit</b> of the <b>VIEW</b>.
    Is there a better way to do this? I find it strange that I have to load the Data from the view.
    Thanks
    Jack

  • Calling a method after 10 seconds

    Hello,
    I need to call a method after 10 seconds. That is to make sure that if one particular field is updated, say 3 times in a window of 10 seconds, I should just be able to take the last value and process it, in my ajax app. I am so far using the Timer class, but the problem is, it ticks off a thread for every single request to be processed after 10 seconds and processes all the 3 requests, where as I should just be running that method once for the last request. Could you please help me with this ?
    Cant do this at the client level, for the page may be closed within those 10 seconds of the event and the setTimeout wont work then.
    This is what I made so far.:
    final Map<String, Object> mp = new HashMap<String, Object>();
    if(form.getEmpId() != null )
                mp.put(form.getEmpId().toString(), form);
                new java.util.Timer().schedule(new java.util.TimerTask()
                   public void run()
                      EmpForm form1 = (EmpForm)mp.get(empId.toString());
                      String empId = form1.getempId().toString();
                      String value1Changed = form1.getValue1Changed().toString();
                      String value2Changed = form1.getValue2Changed().toString();
                      myService.changeData(empId, value1Changed, value2Changed),
                }, 10000);
             }

    Thanks for replying
    tjacobs01 wrote:
    My recommendation is that you share an AtomicReference between your timer and the listener that is receiving the updates. This way, the listener can just update the value, and the timer uses the latest one when it wakes upOk, out of my limited understanding, I looked up AtmoicReference and found it a class. I think I cant use that since I am maintaining a list of empIds against the object that holds their data in a hashmap, expecting the map to override the empId on the second request. So, I made a final map and thought Id just push the timer scheduler method in another method, but the problem is, for me to ask that thread (which I expect to run after 10 seconds of my calling) to run, I need to call it somewhere, and as soon as I get a request I am calling the method which runs/ticks off the thread.
    I was thinking that since I am passing and using a final map (that I declared as a class level variable), I will be able to put update the map object and whenever the thread runs, will fetch the latest value (of the empId) in the map. But I guess I am doing it wrong. :(

  • Calling a method that returns an object Array

    Hello.
    During a JNICALL , I wish to call a method which returns an object array.
    ie my java class has a method of the form
    public MyObject[] getSomeObjects(String aString){
    MyObject[] theObjects=new MyObject[10];
    return theObjects
    Is there an equivalent to (env)->CallObjectMethod(...
    which returns a jobjectArray instead of a jobject, and if not could somebody suggest a way around this.
    Thanks,
    Neil

    I believe an array oj jobjects is also a jobject. You can then cast it to another class.

  • Calling a method from another class or accessing a component from another

    Hi all
    im trying to make a find/replace dialog box
    my main application form has a jtextpane and when i open up the find and replace dialog box it has two textboxes (find and replace)
    now i have the code to do the finding on my jtextpane but how do i call that code to do the find method?
    I have tried having the code in my main application class but then how do i call that method from my dialog box class?
    ive also tried having the code in my dialog box class, but then how to i tell it to work on my jtextpane which is in my main ap class?

    well if someone had been nice enough to provide me
    with a tutorial i wouldnt have gotten into this
    muddle, no need to be rude is there!I'm not rude. And you also wouldn't have gotten into the muddle if you searched yourself. This site provides many very good tutorials about all kinds of stuff.
    http://java.sun.com/docs/books/tutorial/java/javaOO/classes.htmlAmong other things, it mentions that "static" defines everything that belongs to a class, as opposed to an object.

Maybe you are looking for

  • Using a studio display with MacBook Pro

    I have a MacBook Pro and an older 17" Studio Display with a DVI-D male connector. What do I need to drive the studio display from my MBP? And where do I get them?

  • The input or display only attribute of table contorl fileds

    HI,experts in the program there is one parameter p_recount. in my table control ,there are 5 columns, f1 f2 f3 f4 f5 f1 f2 f3 is display only, and if p_recount = 00.,f4 f5 may input but if p_recount != 00. f4 f5 also display only. and when i push the

  • File Filter for a Jlist

    I'm new to filtereing, ive been looking on site and this one, but can't quite get round the filtering process. Most filter examples I've seen are for Filechooser, but this program is a Jlist. I wish to show only one file type, namely an AVI format. C

  • Will apple make downgrade to IOS 5.1 available, IOS 6 too buggy to tolerate?

    An option to reload IOS 5.1 should be made available if Apple wants customer satisfaction. IOS 6 is not stable enough. Apps crashing, wifi problems, battery life, oh yeah no satellite view in weather apps purchased. Not to mention how bad the new map

  • Help for RFC connection

    hi all,        source systems when checked is fine but when i try to customize the extractors it says error "opening" rfc connection..any idea why?? during loading have a error saying idocs not posted and idocs with incorrect status.. help wil be rew