How to access the parent class variable or object in java

Hi Gurus,
I encounter an issue when try to refer to parent class variable or object instance in java.
The issue is when the child class reside in different location from the parent class as shown below.
- ClassA and ClassB are reside in xxx.oracle.apps.inv.mo.server;
- Derived is reside in xxx.oracle.apps.inv.mo.server.test;
Let say ClassA and ClassB are the base / seeded class and can not be modified. How can i refer to the variable or object instance of ClassA and ClassB inside Derived class.
package xxx.oracle.apps.inv.mo.server;
public class ClassA {
    public int i=10;
package xxx.oracle.apps.inv.mo.server;
public class ClassB extends ClassA{
    int i=20;   
package xxx.oracle.apps.inv.mo.server.test;
import xxx.oracle.apps.inv.mo.server.ClassA;
import xxx.oracle.apps.inv.mo.server.ClassB;
public class Derived extends ClassB {
    int i=30;
    public Derived() {
       System.out.println(this.i);                  // this will print 30
       System.out.println(((ClassB)this).i);  // error, but this will print 20 if Derived class located in the same location as ClassB
       System.out.println(((ClassA)this).i);  // error, but this will print 20 if Derived class located in the same location as ClassA
    public static void main(String[] args) { 
        Derived d = new Derived(); 
Many thanks in advance,
Fendy

Hi ,
You cannot  access the controller attribute instead create an instance of the controller class and access the attribute in the set method
OR create a static method X in the controller class and store the value in that method. and you can access the attribute by 
Call method class=>X
OR if the attribute is static you can access by classname=>attribute.
Regards,
Gangadhar.S
Edited by: gangadhar rao on Mar 10, 2011 6:56 AM

Similar Messages

  • Web Dynpro ABAP: How to access the content of a mime object?

    Hi everyone,
    does anybody know how to access the content of a mime object of a Web Dynpro component? I added a XML file as mime object to a web dynpro component. Now I want to read the content of this xml file within a method of the component controller. The code would look something like:
    DATA: xml_content type xstring.
    xml_content = read_mime_object("test_123.xml").
    Any ideas?
    Regards,
    Nils

    dude here's the modification that i've done but I can't still access the content of the properties...
               Mail mail = new Mail();
               String message2 = sqlException.getMessage();
               File file = new File("Add.properties");
               Properties props = new Properties();
               props.load(new FileInputStream(file));
               String[] emailadd = {props.getProperty("emailadd","defaultValue")};
               mail.postMail(emailadd,"An error has occurred, Auto-archive was unsuccessful.", message2,"[email protected]");
               Message was edited by:
    ryshi1264

  • How to print the image data stored in object of 'java.io.File' Class in jsp

    I have created a file object for the image file in the system temporary directory.Now I want to display it in my page. please tell,How to print the image data stored in object(in my program it is imgr) of 'java.io.File' Class in jsp

    Create a servlet which gets an InputStream of the file and writes it to the OutputStream of the response and call this servlet in `src` attribute. That's basically all.
    Here's an example which covers the most of the minimum needs: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • Master-details problem: How to access the parent EO/VO in child side?

    Hello
    Refer to the reply of posting
    Re: How to insert  new records in Master and detail Forms.
    I have got the following questions
    The approach for setting the master-details relationship works well, however, in this example,
    I have overriden the create(AttributeList attributeList) method of VO2, so after calling
    DCBindingContainer dcb = ADFUtils.getDCBindingContainer();
    OperationBinding oper = dcb.getOperationBinding("CreateInsertVO2");
    oper.execute();
    , it will enter the create() method of VO2, at this point, i can only access the argument attributeList
    which stored the key value that link up parent and child, however, how can i get the entire VO1
    for accessing the value of all VO1's attribute?
    Thanks

    Neon wrote:
    I have mapped a createInsert action in the blinding layerThis is OK.
    Neon wrote:
    Do you mean that i have to create createRow and insertRow action in blinding layer?No. The createInsert operation does just that
    Neon wrote:
    Or call these function in the VO overridden create() method?No. You can't do that.
    In conclusion, I don't understand why the accessor returns null. Maybe someone else can shed some light... ?:|
    One last suggestion from me is to try getting the VO1 directly from the AM instead.
    This should work - it is not a recommended practice through.
    Use the following code:
    VO1RowImpl vo1 = (VO1RowImpl)this.getVO1();
    // ensure that the VO1 VL accessor is properly initialized
    if (vo1 == null) {
       vo1 = (VO1RowImpl)((YourApplicationModuleImpl)this.getApplicationModule()).getVO1().getCurrentRow();
    }

  • How to refer the parent class object from an inner class

    Hi,
    I have a class X, which contains an inner private class Y. Class X has a method getY which returns an object of class Y. Class Y has a method getParent. I want to return the object of parent class from this. The code is like this:
    public inerface IY;
    public class X {
    private class Y implements IY {
    public getParent {
    // ... return the object of parent class which created the object of this inner class
    public IY getY() {
    return new Y();
    Can somebody help me with this...

    interface IY {
    public class X {
        private class Y
            implements IY {
            private X parent;
            public Y(X x)
                parent = x;
            public X getParent()
                // ... return the object of parent class which created the object of this inner class
                return parent;
        public IY getY()
            return new Y(this);
    }Filip

  • Accessing the inner class written inside the method

    Hi all,
    Can any of you tell me how to access the inner class's method which is written inisde the outer class's method. THe code fragment is
    class Outer
    private static final int ID = 3;
    public String name;
    public void methodA( int nn )
    final int serialN = 11;
    class inner
    void showResult()
    System.out.println( "Rslt= "+ID );
    } // end class inner
    // new inner().showResult();
    } // end methodA
    class Sample
    public static void main(String a[])
    //access the showResult of Inner class??
    Thanks in advance.
    aah

    class Outer {
      private static final int ID = 3;
      public String name;
      public void methodA( int nn ) {
        final int serialN = 11;
        class inner {
          void showResult() {
            System.out.println( "Rslt= "+ID );
        } // end class inner
        new inner().showResult();
      } // end methodA
    class Sample {
      public static void main(String a[]) {
        new Outer().methodA(5);
    }

  • How to access the hidden variable in jsp

    hi all,
    i need help to know how to access the hidden variable in the same jsp.
    Following is the code snippet just have a look at that.
    ArrayList arrRankingSummary = (java.util.ArrayList)session.getAttribute("arrRankingSummary");
    <logic:iterate id="rankingSummary" name="arrRankingSummary">
    <input type="hidden" name="allApplicantID" value='<bean:write name="rankingSummary" property="APPLICANTID"/>' />
    <input type="hidden" name="allAdmissionRank" value='<bean:write name="rankingSummary" property="ADMISSIONRANK"/>' />
    </logic:iterate>
    <input type="hidden" name="applicantID" value='<bean:write name="rankingSummary" property="APPLICANTID"/>' />
    <TD align=center><Input type=Text name="admissionRank" class=Textverysmall size=2 value='<bean:write name="rankingSummary" property="ADMISSIONRANK"/>' maxlength="10" /> </TD>
    I want to remove the element from arraylist on these condition
    if(allApplicantID.value ==applicantID.value){
    arrRankingSummary .remove("admissionRank");
    Now the pbm is i m not getting how to access the hidden variable in jsp or how to use the values of hidden variable for the condition.
    Pls help me out.
    Thanks in adv.
    Regards,
    Ritu

    hi ram,
    as i mentioned i m creating hidden variables & i m doing some validation on form submit.
    The following is js code snippet for validation.
    for (var i = 0; i < document.forms[0].admissionRank.length; i++)
    admissionRank = document.forms[0].admissionRank.value;
    for(var j = 0; j < document.forms[0].allAdmissionRank.length; j++)
    //alert ("admissionRank : " + admissionRank + " document.forms[0].allAdmissionRank[" + j + "].value : " + document.forms[0].allAdmissionRank[j].value + "\ndocument.forms[0].allApplicantID[" + j + "].value : " + document.forms[0].allApplicantID[j].value + " document.forms[0].applicantID[" + i + "].value : " + document.forms[0].applicantID[i].value);
    if(admissionRank == document.forms[0].allAdmissionRank[j].value && document.forms[0].allApplicantID[j].value != document.forms[0].applicantID[i].value && admissionRank != "" && document.forms[0].allAdmissionRank[j].value != "")
    flag = false;
    document.forms[0].admissionRank[i].focus();
    document.forms[0].admissionRank[i].select();
    break;
    if (flag == false)
    break;
    In this validation i want admissionRank to be removed from the original arraylist if following condition gets satisfied
    "(document.forms[0].allApplicantID[j].value == document.forms[0].applicantID[i].value )"
    Thanks in adv
    Ritu

  • How to get the parent window in sub-child controller class in javafx?

    how to get the parent window in sub-child controller class in javafx?

    You can get the window in which a node is contained with
    Window window = node.getScene().getWindow();Depending when this is invoked, you might want to check the Scene is not null before calling getWindow().
    If the window is a stage that is owned by another window, you can get the "parent" or "owner" window with
    Window owner = null ;
    if (window instanceof Stage) {
      Stage stage = (Stage) window ;
      owner = stage.getOwner();
    }

  • How to get the class name  static method which exists in the parent class

    Hi,
    How to know the name of the class or reference to instance of the class with in the main/static method
    in the below example
    class AbstA
    public static void main(String[] args)
    System.out.println(getXXClass().getName());
    public class A extends AbstA
    public class B extends AbstA
    on compile all the class and run of
    java A
    should print A as the name
    java B
    should print B as the name
    Are there any suggestions to know the class name in the static method, which is in the parent class.
    Regards,
    Raja Nagendra Kumar

    Well, there's a hack you can use, but if you think you need it,Could you let me the hack solution for this..
    you probably have a design flaw and/or a misunderstanding about how to use Java.)May be, but my needs seems to be very genuine..of not repeat the main method contents in every inherited class..
    The need we have is this
    I have the test cases inheriting from common base class.
    When the main method of the test class is run, it is supposed to find all other test cases, which belong to same package and subpackages and create a entire suite and run the entire suite.
    In the above need of the logic we wrote in the main method could handle any class provided it knows what is the child class from which this main is called.
    I applicate your inputs on a better way to design without replicating the code..
    In my view getClass() should have been static as the instance it returns is one for all its instances of that class.
    I know there are complications the way compiler handles static vars and methods.. May be there is a need for OO principals to advance..
    Regards,
    Raja Nagendra Kumar
    Edited by: rajanag on Jul 26, 2009 6:03 PM

  • How to access the Custom Data type variable given in Expression edit control To and From LabVIEW

    Hello, I would like to know how to access the custom data type variable given in the Espression Edit Control from LabVIEW and vice-versa
    Say, the FileGlobals.Reference_Handle (Custom Data Type Variable) contains the
    VISA I/O session (Which in turn contains VISA_DeviceName: String, Session: Number),
    Channel1: Number and
    Channel2: Number
    I am expecting the user to give FileGlobals.Reference_Handle as the input at the ExpressionEdit Control in the edit screen of the VI Call.
    I would like to know how to get the values of this custom data type to LabVIEW?
    Say, if I have the Cluster in LabVIEW like VISA I/O session (Deive Name and Session Number), Channel1 and Channel2
    how do i need to set this cluster to the Custom Data type variable in TestStand?
    Thanks and Regards
    Prakash 

    Hi,
    TestStand to LabVIEW: i didnt understand what you r trying to achieve. But if you are using references, Use Property nodes and Invoke nodes to achieve what you want in LabVIEW.
     LabVIEW to TestStand: check the image below: You need to click the button next to 'container'. I have used a cluster output in the VI.
    Hope this helps
    .......^___________________^
    ....../ '---_BOT ____________ ]
    ...../_==O;;;;;;;;_______.:/
    Attachments:
    1.JPG ‏187 KB

  • OOABAP-How to access the protected methos from a class

    How to access the protected methos from a class..There is a built in class..For tht class i have created a object..
    Built in class name : CL_GUI_TEXTEDIT
    method : LIMIT_TEXT.
    How to access this..help me with code

    hi,
    If inheritance is used properly, it provides a significantly better structure, as common components only
    need to be stored once centrally (in the superclass) and are then automatically available to subclasses.
    Subclasses also profit immediately from changes (although the changes can also render them invalid!).
    Inheritance provides very strong links between the superclass and the subclass. The subclass must
    possess detailed knowledge of the implementation of the superclass, particularly for redefinition, but also in
    order to use inherited components.
    Even if, technically, the superclass does not know its subclasses, the
    subclass often makes additional requirements of the superclass, for example, because a subclass needs
    certain protected components or because implementation details in the superclass need to be changed in
    the subclass in order to redefine methods.
    The basic reason is that the developer of a (super)class cannot
    normally predict all the requirements that subclasses will later need to make of the superclass.
    Inheritance provides an extension of the visibility concept: there are protected components. The visibility of
    these components lies between that of the public components (visible to all users, all subclasses, and the class itself), and private (visible only to the class itself). Protected components are visible to and can be used by all subclasses and the class itself.
    Subclasses cannot access the private components  particularly attributes) of the superclass. Private
    components are genuinely private. This is particularly important if a (super)class needs to make local
    enhancements to handle errors: it can use private components to do this without knowing or invalidating
    subclasses.
    Create your class inse24 and inherit this CL_GUI_TEXTEDIT
    class in yours. You can then access the protected methods.
    Hope this is helpful, <REMOVED BY MODERATOR>
    Edited by: Runal Singh on Feb 8, 2008 1:08 PM
    Edited by: Alvaro Tejada Galindo on Feb 19, 2008 2:19 PM

  • How to access the text symbols of a class

    Hi Experts,
    Can anyone pl. tell me how to access the text symbols of a class.
    Thanks,
    Uday.

    Hi,
    Please check
    http://help.sap.com/saphelp_nw04s/helpdata/en/43/1f6442a3d9e72ce10000000a1550b0/frameset.htm

  • How to access the handle of  the Frame window ?

    How to access the handle of the frame window through out the application ?. I want to display an alert box, while I click the fifth inner child component of the Frame . I am using Dialog Class for the alert box, I have to pass the frame handle to the Dialog constructer, I am getting the handle of the frame by getParent().getParent()......getParent().. But can any one suggest any better solution.

    If you application extends Frame or JFrame, you could simply refer to "this", or if you create a global or final Frame object that you use as your "top-level" component, you could refer to it this way. Additionally, if you're ever in a situation where you really need to go all the way to the top through n levels of components, I believe you could always do something like this...
    // assume myContainer is the "child" component that you're on, and you want to find its top-level parent
    Container c = myContainer;
    while (c.getParent() != null) {
         c = c.getParent();
    }

  • How to use the different class for each screen as well as function.

    Hi Experts,
    How to use the different class for each screen as well as function.
    With BestRegards,
    M.Thippa Reddy.

    Hi ThippaReddy,
    see this sample code
    Public Class ClsMenInBlack
    #Region "Declarations"
        'Class objects
        'UI and Di objects
        Dim objForm As SAPbouiCOM.Form
        'Variables
        Dim strQuery As String
    #End Region
    #Region "Methods"
        Private Function GeRate() As Double
                Return Double
        End Function
    #End Region
    Public Sub SBO_Appln_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            If pVal.BeforeAction = True Then
                If pVal.MenuUID = "ENV_Menu_MIB" Then
                End If
            Else ' Before Action False
                End If
        End Sub
    #End Region
    End Class
    End Class
    Rgds
    Micheal
    Vasu Anna Regional Feeling a???? Just Kidding
    Edited by: micheal willis on Jul 27, 2009 5:49 PM
    Edited by: micheal willis on Jul 27, 2009 5:50 PM

  • How to get the extension Info from firefox? Do we have any firefox API to communicate with the browser? I couldnt see the HTML of the widget displayed in the toolbar how to access the widget using JS or any way

    How to get the extension Info from firefox? Do we have any firefox API to communicate with the browser? I couldnt see the HTML of the widget displayed in the toolbar how to access the widget using JS or any way

    Hi,
    Thanks for the suggestion. I've been playing around with some of the classes of the java.net package and java.io
    Using the URL class i can get the content of the data from a STATIC page and output that response to file so that is does not display to the client broswer.
    But this only works if the URL i give points to a static html page.
    So the problem i'm getting is if i'm righting in arguments in the URL, this means that server needs to process the arguments i give and its sends back a dynamic result. Because its dynamic the URL class can not handle this and throws me an exception everytime :(
    Have u ever tried to do some things like this?
    Rahul

Maybe you are looking for

  • Refresher on how to download programs to my new Imac.

    I just bought a refurbished Imac G5 and wanted to use word but it has expired since it only comes with the 30 day trial from 2004. So i purchased the program now i want to instal it. but dont know how. Do i need something else to instal programs? ple

  • Is there a way to remove fields from a "Simple Contact" form?

    What I am looking to do is create a "subscribe to newsletter" form where the user only has to enter their email address. I don't want them to have to enter their name or write a message. Does anyone know if it is possible to alter the simple contact

  • Watch Window greyed out

    Hallo When running in debug mode I got the breakpoints in the code, everything with the watch window is greyed out, even if I right click on a variable the add to Watch is greyed out. I've done a Tools ---> Import Export Setting ---> Reset defaults.

  • Mp3 tracks not in numerical order

    For some reason when I use my flash drive in the car the songs dont play in numerical order. I realized the same thing happens when I add those same songs to iTunes. Is there is program mac compatible of course that can solve this problem?

  • Exporting my movie lets flash pro cs5.5 crash

    Hi, i have a problem when i try to export my movie. It just crashes. I don't know what to do anymore. I cannot work anymore!! where can i get help with this? sincerely hoping for help, Uli Genenger Liluc Design