Passing an object of the UiApplication class reference

Hi all

I am very new to the development of BB and have struggled for hours on something that I think should be very simple. What I have, this is the main class that extends UiApplication and a second class that implements Runnable. From a method in the UiApplication class, I create an instance of the Runnable class. After that, I call a method to start from this class and pass an object originally from the UiApplication class reference - so that I can call a method, once completed the processing of the Runnable class.

The problem I have, is that once past the object through a call to method reference, the reference instantly cancels and causes a NullPointer exception when trying to call a method in the original class. The structure is as below, but with all the surrounding code subscribed:

public class MainApp extends UiApplication {

    MainApp _MainApp;
    OtherClass _OtherClass;

    public static void main(String[] args) {
    MainApp _MainApp = new MainApp();
    _MainApp.enterEventDispatcher();
    }

    private void createOtherClass() {
        _OtherClass = new OtherClass();
        _OtherClass.someMethod(_MainApp);
    }

    public void response() {
        // code here
    }
}

public class OtherClass implements Runnable {

    MainApp _MainApp;

    public void someMethod(MainApp MainAppRef) {
        _MainApp = MainAppRef;
        // _MainApp object reference is null here

        new Thread(this).run();
    }

    public void run() {
        // stuff here
        // once done, call a different method
        sendDetailsBack();
    }

    public void sendDetailsBack() {
        _MainApp.response(); // causes a NullPointerException
    }
}

I rewrote this to only show the code at the source of the problem. I don't quite understand why the object reference is not passed correctly - I have tried many other ways to call back to the UiApplication function, including static calls.

Any help on how I do it is very appreciated!

Will be

I suspect that your problem is here:

MainApp _MainApp = new MainApp();

I think you meant just

_MainApp = new MainApp();

Tags: BlackBerry Developers

Similar Questions

  • How to pass an object of the stored procedure?

    Hello.

    After reading the documentation online 'The JDBC Oracle9i developer reference Guide' how to use oracle.sql.STRUCT to pass the java classes to database objects and how do the same thing in the sense opposite, I still don't know how to do what I need, I would like to know a few resourse online where I could find more examples.
    I guess it must be quite easy to do.

    I learned to create a java class that will be used to call a stored procedure (9i database) that has a single input/output parameter whose type is a user-defined object.

    I'm trying to do something similar, by I was not able. This is my essay:

    CREATE OR REPLACE TYPE                  FERNANDO.TIPOBD AS OBJECT (   ID INTEGER,   NOMBRE VARCHAR2(50),   HORA TIMESTAMP ); / CREATE OR REPLACE PACKAGE FERNANDO.prueba_java AS   PROCEDURE prueba (objetoJava IN OUT TIPOBD); END prueba_java; / CREATE OR REPLACE PACKAGE BODY FERNANDO.prueba_java AS   PROCEDURE prueba (objetojava IN OUT TIPOBD)   AS   BEGIN       NULL;   END prueba; END prueba_java; /
    import java.sql.*; //import oracle.sql.*; import oracle.jdbc.*; import oracle.sql.*; public class Prueba { public static void main(String[] args) { Connection conexion = GestorConexion.getConexion(); if (conexion != null) {   try {     DatabaseMetaData meta = conexion.getMetaData();     System.out.println("JDBC driver version is " + meta.getDriverVersion()); int num = 0; String consulta = "select 1 from dual"; PreparedStatement ps = conexion.prepareStatement(consulta); ResultSet rs = ps.executeQuery(); if (rs.next()) { num = rs.getInt(1); } System.out.println("num == "+num); ObjetoOracle oo = new ObjetoOracle(1, "Fernando", new Timestamp(1) ); System.out.println("id: "+oo.getId()+"; nombre: "+oo.getNombre()); // Se llama al procedimiento almacenado String llamada = new String(); llamada += "BEGIN "; llamada += "  FERNANDO.prueba_java.prueba(?)"; llamada += "END;"; StructDescriptor structdesc = StructDescriptor.createDescriptor("FERNANDO.TIPOBD", conexion); STRUCT struct = new STRUCT(structdesc, conexion, null); OracleCallableStatement ca = (OracleCallableStatement)conexion.prepareCall(llamada); //ca.setObject(1, oo); ca.setObject(1, null); ca.registerOutParameter(1, OracleTypes.JAVA_OBJECT); ca.execute(); } catch (SQLException sqle) { System.out.println(sqle.toString()); } } else { System.out.println("CONEXIÓN con bd nula"); } } }

    My if intend to create an oracle.sql.STRUCT object that I'll pass to the procedure and then get back to the procedure, but I can not even create the StructDescriptor.
    It is the output that I get:

    Conexión con BD ok JDBC driver version is 9.2.0.8.0 num == 1 id: 1; nombre: Fernando java.sql.SQLException: Tipo no definido: get_next_type

    Any help would be welcome. Thanks in advance.

    You must add the name of the type of your call registerOutParameter (.).
    ca.registerOutParameter ("", OracleTypes.JAVA_OBJECT, FERNANDO. TIPOBD);

    You can consider using OracleTypes.STRUCT instead of JAVA_OBJECT.

    You must also change your call set *;.
    ca.setObject ("", FERNANDO of the object. TIPOBD, OracleTypes.STUCT);

    You can use the same string parameter "" to the two parameters or
    You can use the same parameter INT for both parameters.

    You cannot combine parameters named and numbered together. I was using both for a single method or both using the other.
    The syntax may be different according to the method you in order to verify the Java Doc.

  • Error 1448. LVOOP: Referring to objects of the child class

    Hi all.

    In a project using LVOOP, I defined a class parent with several attributes. Of this class, there are three classes of children who inherit the attributes of the parent class and also have their own.

    Imagine that I instantiated an object belonging to the parent class and initialize its attributes. So I want this object even belong to a class of the child in particular, and refer to its attributes in the class of the child, of course, keep the values of the parent class. How can I do?

    I tried to use "in a more specific class" tool but I get the following text: "error 1448: bad type cast." LabVIEW does not deal with the run-time value of this class of LabVIEW as an instance of the given class of LabVIEW. »

    Exactly the same problem is committed and solved here http://lavag.org/topic/7473-lvoop-class-variable-as-child/, but because the links are temporarily disabled I can't download and understand the code example, which shows what it says there.

    Thank you very much
    Francisco.

    Hi Francisco,.

    Take a look at this thread: http://forums.ni.com/ni/board/message?board.id=170&message.id=362388&requireLogin=False

    Christian

  • Pass a variable to the main class to a MovieClip

    Hello!

    I have a document with the main class.

    I have also a few clips that have their own class and functions.

    I'm trying to pass a variable in my main class to one of these clips.

    I tried a few things, nothing has worked.

    Who can help?

    Match_Easy looks like a class name.  You must use the name of the instance.

  • Properties of the objects in the original application reference

    I continue to ask this question, maybe it's the wrong question,

    but here again:

    Why can't change properties in the main application for a component of the original application?

    Thank you

    Doug

    change of the cn you... but the best way is to loosely couple both the parent and the child of the parent using the communication of custom events/event based.

    so, to use in this case custom events.

    http://cookbooks.Adobe.com/post_Very_simple_example_of_using_custom_events_to_pass-15466.h tml

    Oops... Looks like I already helped you on this...... Laughing out loud! still struggling?

    Post edited by: saisri2k2

  • Passing an object of class SolidColor()

    Hello! I want to move an object in the SolidColor class in a single sentence (object), but I get an error: object expected.

    I think I'm passing an object... but I don't know what the problem is: S

    as:

    var color = new SolidColor()

    Color.RGB = {'red': 255, 'green': 255, 'blue': 255}; < -.

    app.backgroundColor = color;

    Instead of:

    var color = new SolidColor()

    Color.RGB.Red = 255;

    Color.RGB.Green = 255;

    Color.RGB.Blue = 255;

    app.backgroundColor = color;

    Thank you!!!

    The only way to do it in one line is:

    app.backgroundColor.rgb.hexValue = "FFFFFF";

  • linking the name of the object to the object outside the scope

    In the first function homeL adds the text field "restMenu", when it is called. In another function, the hideTarget method is called and it checks to see if the name of the objects is "instance5" which is the name of homeL. Is it possible to connect a name of objects to the object because I get:

    The supplied DisplayObject must be a child of the caller.

    at flash.display::DisplayObjectContainer/removeChild()

    When I try to use the line in bold. BTW, little code has been removed to illustrate the point.

    function showTarget(obj:Object):void {}

    var i: int = getTarget (obj);

    var restMenu:TextField;

         j++;

    If (I == 0 & & j == 4) {}

    restMenu = getRest ("home"); the rest of the menu shows

         }

    getter.menuObject = restMenu;

    If (restMenu! = null) {}

              if (j == 4) {

    homeL.addChild (getter.menuObject);

              }

    }

    }

    function hideTarget(obj:Object):void {}

    If (getter.menuObject! = null & & obj.name == "instance5") {}

    homeL.removeChild (getter.menuObject);

         }

    }

    You can use getChildByName() applied to the parent of objects to retrieve an object for the name property reference.

  • Get and set data using the ActionScript class

    Hello

    I use the ActionScript class to store the user name and password when the user logs


    com package
    {
    public class Login
    {
    public function Greeter (initialName:String = "")
    {
    }

    public var uname:String;
    password public var: String;

    }
    }

    Inside the Componet Login form, I am creating the object of this class of connection and affecting the data as shown in it

    var logincomp:Login = new login());

    logincomp.uname = UnameTI.text;
    logincomp. Password = PassTI.text;


    I need these data within an another CustomComponent, is it possiblke to access these data within an another componnet.

    Can I do this?


    var logincomp:Login = new login());

    var str:String = new String();

    Str = logincomp.uname;


    Please me tips


    I know it's possible with recording and Dispatching Evenets
    However, I'm not interested to use DEMONSTRATIONS. I'm using FLEX 3

    Please advise me if this is possible.

    THnaks in advance.

    Thanks for helping me learn Flex quickly.

    Hello

    You use a Singleton class as (class ModelLocator) If Yes, then you can put a single instance of your connection class in this class so that you can access this instance in the world in any component (infact with the app).

    Declare an instance of the connection object in the Singleton class like below

    var logincomp:Login = new login());

    Set the values in a single component, and you can access the values in the other component.

    The sample class Singleton as shown below...

    package com.model
    {

    [Bindable]
    public class ModelLocator
    {
    private static var instance: ModelLocator;
     
    public var logincomp:Login = new login());
     
    public void ModelLocator()
    {
    If (instance! = null)
    {
    throw (new Error ("cannot only one instance of ModelLocator"));
    }
    }
    Public Shared function getInstance (): ModelLocator
    {
    if(instance == null)
    {
    instance = new ModelLocator();
    }
    return instance;
    }
    }
    }

    If this post answers your question or assistance, please mark it as such.

    Thank you

    Jean Claude Chari

  • Adding objects to the stage &amp; amp; Properties of the acceessing Stadium - I'm a bit confused...

    Hello

    I'm a bit confused about the programming of the display's two-pronged:

    A. What are the best way to add objects to the stage?
    B. how to access the properties of the step.

    I can make these two when the project is a 'Action Script Project', but I have a problem when it is a "Flex project" (for example a MXML file). See the attached files two questions included in the commentary to see exactly what I mean.


    A. What are the best way to add objects to the stage?
    =====================================

    In a project of action script which extends Sprite I can call him addChild()

    In a project MXML I add objects to the scene first, adding them to a UIComponent, then adding that the step.

    1 - is the best way to do it?

    In this doc: http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html he says this quote from
    :
    Each SWF file has an ActionScript class associated with it, called the main class of the SWF file. When Flash Player opens a SWF file in an HTML page, Flash Player calls the constructor function for that class and the instance that is created (which is always a type of display object) is added as a child of the Stage object. The main class of a SWF file always extends the Sprite class
  • Typedef reference FPGA not updated in the private class data

    I have a FPGA reference related to a typedef that is passed in a LVOOP object. If I change the FPGA of computer simulation of dev to the use of the actual hardware, all references to the typedef are updated which are controls on a diagram. But the typedef in my private class data seems not not to date, so I'm broken son until I replace the control to private data of my class with a copied from my block diagram. Has anyone seen this? Is there a CAR already? I can create a small project to reproduce if necessary.

    Edit: this also seems to happen when I change bitfiles or change to open a VI a bitfile opening in the Configure dialog box open FPGA VI.

    Hi Greg,.

    I was able to reproduce your problem thanks to your easy to follow instructions.

    I noticed that type def successfully by checking "Bind FPGA host of reference to the type definition" in the open FPGA VI reference configuration. What does not automatically update is the Issue.ctl of OBJECT-oriented programming, which has a nested type definition in the private data reference.

    The fastest solution, that I could find was to right click on "Issue.ctl" in the project, and then click Save. This problem immediately solved the broken wire error.

    While configuring open FPGA VI reference has the practical ability to bind to the def of type, it does not broadcast this change to data private to the class. I call not this bug, but I can see how you want it works this way.

    I would recommend you post that on theExchange of ideas (I see you're already regularly here).

  • Help contains no description for instance through me class reference and dialog object via this

    Hi DIAdem,

    I have a tiara 2015 SP2 version.

    The Scipt VB has a possibility to refer to an instance of the current class by me. It is sometimes important and useful. It works in tiara. But it is not described in the help of DIAdem.

    Tiara provides a reference to the current object SOUTH via this. It is not described in the help too.

    Can you tell us why or you can add it to future versions of the help / DIAdem?

    Thank you.

    Hi Sasha_62

    You can use 'This' in the Calculationscript for the calculation, in the Barmanger and in the SOUTH Editor.

    You're right, 'This' and 'Me' is not or not very obvious described in the help of tiara and we will try to do better in the next version.

    Thanks for the suggestion.

    Winfried

  • the ActionScript class code vs / where my objects in scene gone?

    KSK

    I had a configuration 2 frame with some actionscript for each image.

    Tried to move everything in a class file and a 1 frame. Fla. ; Hiding and showing the moviclips resp. When I move virtually 1 in box 2 chassis.

    Now I get these... Error #1069: Edit_panel_mc property not found on flash.display and there is no default value.

    errors or...

    When I thought smart beeing adding scene. prefix

    ReferenceError: Error #1069: property not found on flash.display.Stage edit_panel_mc and there is no default value.

    The mc is on the scene... I have a single .as classfile.

    Why can't I reference them? or how I should do / what should I do to change the script .fla beeing in the script of the class.

    Help, please...

    Mac

    your document class can refer to any object on the stage in frame 1.  whatever in box 2 can not be referenced until this image is rendered.

    so, where's edit_panel_mc?  is it on the stage in frame 1?

  • To access the display object on the stage of another class

    I Googled that nothing helps, I only found how to manipulate the scene itself and not a display on that object and I'm noob enough to not be able to figure it out from there. :/

    I have a clip on the main timeline with the instance name displayName. I created a button that should change this framework displayName will to (in order to... makes you guess? display the name of the button.) Awesome. )

    So, I'm trying to write the code in a reusable manner and have everything related to a class called GeoPuzzle buttons. Inside the GeoPuzzle I instantiate a touch event and run code. However, the function should be able to change displayName in the main part of the timeline and, of course, the compiler says displayName does not exist because I'm in a class and I don't mean the scene.

    Here's the code simplified in the class:

    package com.freerangeeggheads.puzzleography {}
    import flash.display.MovieClip;
    import flash.events.TouchEvent;

    SerializableAttribute public class extends MovieClip {} GeoPuzzle
    declaring variables

    public void setInitial (abbrev:String, fullName:String, isLocked:Boolean): void {}
    Set the parameters
    this.addEventListener (TouchEvent.TOUCH_BEGIN, geoTouchBeginHandler);
    }

    public void GeoPuzzle (): void {}
    }

    public void geoTouchBeginHandler (e:TouchEvent): void {}
    e.target.addEventListener (TouchEvent.TOUCH_END, geoTouchEndHandler);
    other methods
    nameDisplay.gotoAndStop (e.target.abbrev);
    }

    public void geoTouchEndHandler (e:TouchEvent): void {}
    other methods
    nameDisplay.gotoAndStop ("USA");
    }
    }
    }

    The lines in bold are my problem. Now this code does not actually as it is the case if you find an error in it, Yes, I have no idea what the problem is, but he DID run forward and these lines always gave me wrong so I'll try to help out on multiple fronts.

    How can I say displayName to change its current image within the display object class?

    Thank you!

    any display list object can refer to any display list object, but this is not necessarily good OOP.

    in any case, for your class reference displayName:

    . DisplayName MovieClip (this.parent)

  • Create an object of value and packaging in the event class

    IM learning to create an object of value - according to the tutorial I first create a class that I pass the variables to.
    I then create an event class to encapsulate the above class. in the event class I get the 1203 error no default constructor in the base flash.events.Event class

    Here's the class

    your Builder RegisterEvent() implicitly calling event
    of constructior and says error event does not provide a default constructor (no args) defined.
    You must change your Builder and args announces to her.

    for example like this:

    public void RegisterEvent (type: String, regParam:RegisterVO, bubbles: Boolean = false, cancelable: Boolean = false) {}
    Super (type, bubbles, cancelable);
    This.reg = regParam;
    }

  • Can't place separator reference in the private class data control

    Any reason, I can't drag and drop a splitter reference leave my block diagram to a private open class data control? Basically, I'm ignored when I let it go, even if I see an icon 'drop' after that I drag the control.

    Well, I think I got smart and just placed a generic control Refnum into the command group, and then used the VI of the server class to identify it as a separator. Interesting how I could drag and drop references to the sub-panels and other types but not a divider.

Maybe you are looking for

  • How to add and remove items in the bookmarks toolbar?

    I want to remove items in the bookmarks toolbar and add those that I use on a regular basis. How can I do this?

  • Photo in full screen tv

    How can I have my photos on the screen of the TV that all go full screen.  With the help of a mini display to hdmi cable.

  • I cannot print pdf files

    my name is briceI cannot print the PDF of my windows vista home basic actually get a print where the words are strange characters and lines appear normal. I can print any other documents.Please help me

  • Windows Desktop problem because I can not see the desktop but only Windows Explorer

    Hi everyone, I have problem with windows 7, when windows lights, showed no office, only to see the Explorer window, when you type Explorer on track, re - opens the Explorer window. do not display the taskbar, show no office. Windows 7 (please do not

  • Playbook free eligibility question

    Hello. I had a question: I submitted an application and had a code signature problem. When I discovered a solution, I discovered that I needed to have the same code as before key signing, and I do not have... So I renamed my old APP (Appname) - delet