Data persistence of another class

Hello world. I have a class with an EditField where a user can enter his name. It can successfully be registered and loaded the class, but I'm trying to load the name on the Welcome screen when the next run of the application.

ProfileBuilder.java

Class ProfileBuilder {}

EditField firstNameEdit. PersistentObject namePersist;

public static final long KEYS = 0xb724a0bb0280b11aL;

{ProfileBuilder()}

...

firstNameEdit = new EditField("","");

...

Add (firstNameEdit

}

public void save() throws IOException {}

namePersist.setContents (firstNameEdit.getText ());

namePersist.commit ();

}

}

--------------------------------------

Class of the Welcome screen

Menu.Java

{Class menu

Menu() {}

If (ProfileBuilder.firstNameEdit! = null) { }

name = (String) ProfileBuilder.namePersist.getContents ();

I forgot initialize the PersistentObject Duh!

namePersist = PersistentStore.getPersistentObject (KEY);

Tags: BlackBerry Developers

Similar Questions

  • (Question LVOOP) How one access the data of another class in another class?

    Hello-

    Ass title suggests, how do I access another class (or is it class?) data from another (different) class?  I will attach a picture showing where my problem is...

    I was told this:

    http://zone.NI.com/reference/en-XX/help/371361H-01/lvhowto/setting_scope_classes/

    May contain some helful info, but I can still understand how to unbundle Renault of classes inside the component class data (as seen in the attached photo).

    I think there could be something simple I'm missing here when it comes LVOOP or OBJECT-oriented programming in general... If any of you are willing to help me, it would be much appreciated!

    Thank you!

    -pat

    Personal data are always private, you can never set public. Unbundle cluster function can be used only on the thread of class when he is in the class. If you need to access private data, you must create accessors.

    It of simple, just the class right click and select new, VI for access data members. He invites you to a dialog box to fill you with what you want to create, elements of data and if you want them available through property nodes (recommended). Once completed, this will generate the Afterward screw., you can use in any other VI. The nice thing about making them nodes of property is that you can plop down a property node and it thread class, and all the created accessor functions will appear in the list.

  • How to send data to another class?

    I have two classes, the main class and class data.
    Main class creates multiple instances of data class, and it also has a variable to the collection of the messages in this case. If the code goes like this:


    myData import;

    main/public class extends MovieClip {}

    report of the var: String;

    public void main() {}
    addEventListener (Event.ADDED_TO_STAGE, init);
    }

    private void init(event:Event):void {}
    var a: myData = new myData ("file to process 1");
    var b:myData = new myData ("process 2 file");
    var c:myData = new myData ("file in 3");
    }

    }

    Data class attempts to load the file specified from different locations, chargers, headphones, and others, and I would as as listener to report what happens during and after loading the data into the main class.

    public class myData {}
    public void myData(fname:String) {}
    Charger code "fname".
    COMPLETE and ERROR listeners
    }

    onError() {} function
    Send message to the report in the main class
    }

    function onComplete() {}
    Send message to the report in the main class
    }

    }

    It is the normal way of doing things and how do I make it work?
    I can not access the variable 'report' from inside the class, and I don't know if I can refer to the main class of inside the data class

    For example:

    package
    {
         import flash.events.Event;
         import myData;
         public class main extends MovieClip{
              public var report:String;
              private var a:myData;
              private var b:myData;
              private var c:myData;
              public function main() {
                   addEventListener(Event.ADDED_TO_STAGE,init);
              }
    
              private function init(event:Event):void {
                   a = new myData("file to process 1");
                   b = new myData("file to process 2");
                   c = new myData("file to process 3");
    
                   a.addEventListener(myData.COMPLETE, onComplete);
                   b.addEventListener(myData.COMPLETE, onComplete);
                   c.addEventListener(myData.COMPLETE, onComplete);
    
                   a.addEventListener(myData.ERROR, onError);
                   b.addEventListener(myData.ERROR, onError);
                   c.addEventListener(myData.ERROR, onError);
              }
    
              private function onComplete(e:Event):void {
                   removeListeners();
              }
    
              private function onError(e:Event):void {
                   removeListeners();
              }
    
              private function removeListeners():void {
                   a.removeEventListener(myData.COMPLETE, onComplete);
                   b.removeEventListener(myData.COMPLETE, onComplete);
                   c.removeEventListener(myData.COMPLETE, onComplete);
                   a.removeEventListener(myData.ERROR, onError);
                   b.removeEventListener(myData.ERROR, onError);
                   c.removeEventListener(myData.ERROR, onError);
              }
         }
    }
    

    And in the data class:

    package
    {
         import flash.events.Event;
         import flash.events.EventDispatcher;
         public class myData extends EventDispatcher {
              public static var COMPLETE:String = "loadComplete";
              public static var ERROR:String = "loadError";
              public function myData(fname:String) {
                   // 'fname' loader code
                   // COMPLETE and ERROR listeners
              }
              private function onError(e:Event):void {
                   // send message to report in main class
                   dispatchEvent(new Event(COMPLETE));
              }
              private function onComplete(e:Event):void {
                   // send message to report in main class
                   dispatchEvent(new Event(ERROR));
              }
         }
    }
    

    Post edited by: Andrei1

  • 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

  • How do I know if a class LV object has a relationship of 'is - a' with another class?

    Hi all

    I have a question LVOOP.

    Let's say I have a class object. The class of the object, it's that I have developed. Now, I would like to know if the object has a relationship of 'is - a' with another class.

    How can I do?

    One solution I have is to use "more specific class ' and check the status of the error. But I thought that there is a better way that I don't know.

    Thank you

    TailOfGon wrote:

    One solution I have is to use "more specific class ' and check the status of the error. But I thought that there is a better way that I don't know.

    It is the right solution. What dislikes on this subject?

  • Back in another class vector

    I am trying to create a vector in my class of network. I want to fill my popup screen with the same vector. Can someone tell me how I would return the vector in another class where my popup is called from.

     final class NetworkGetConnectionClassGeoCode 
    
    System.out.println(address);
    _datageocode.addElement(new DataGeoCode(address)); 
    
    class DetailScreen extends FullScreen 
    
    public void showDialog() { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { CustomPopup screen = new CustomPopup(NetworkGetConnectionClassGeoCode.,_data.getAddress()); _controller.getUiApplication().pushModalScreen(screen); String newEndPoint = screen.getEndPoint(); String newStartingPoint = screen.getStartingPoint(); } }); }
    

    Hi onelson06,

    You can create a static vector in your invocation class. so if you have a static vector in DetailScreen, just fill in your popup via DetailScreen.yourstaticvector.addElement ().

    or you can create a static method in your class that is invoking as setVectorData(Vector v) and invoke this in your pop-up screen to move to the previous screen.

    I hope this helps.

    Cheers!

  • Using a function from another class

    Information: Blackberry JDE 7.1.0

    BlackBerry 9930 Simulator - V 4.0.0.141

    The title of the topic seems simple, but I'm actually trying to use a X of class A function inside a function Y of class B and the GET, the value returned by X to a variable in B.

    Let me start by explaining what I currently have and then go on what I'm doing.

    I am using this class, the code for which I found online, to create a scrollable multi-line textbox.

    public class TextBoxField extends VerticalFieldManager {
    
          //define some variables to be used
          //in the class
          private int managerWidth;
          private int managerHeight;
          private EditField editField;
    
          public TextBoxField(int width, int height) {
                super(Manager.NO_VERTICAL_SCROLL);
                managerWidth = width;
                managerHeight = height;
    
                VerticalFieldManager vfm =
                    new VerticalFieldManager
                      (Manager.VERTICAL_SCROLL);
    
                  editField = new EditField(){
                    public void paint(Graphics g) {
                    getManager().invalidate();
                    super.paint(g);
                  }
                };
    
                vfm.add(editField);
                add(vfm);
              }
    
          public void paint(Graphics g) {
              super.paint(g);
              g.drawRect(0, 0, getWidth(), getHeight());
            }
    
          public void sublayout(int width, int height) {
              if (managerWidth == 0) {
                managerWidth = width;
              }
              if (managerHeight == 0) {
                managerHeight = height;
              }
              super.sublayout(managerWidth, managerHeight);
              setExtent(managerWidth,managerHeight);
            }
    
          public String getText() {
                return editField.getText();
              }
              public void setText(String text) {
                editField.setText(text);
              }
            }
    

    Then in another class that I created a "Set" function that instantiates the class textbox, to create two text boxes and a richfieldtext, add them to a HorizontalFieldManager and return the HorizontalFieldManager.

     HorizontalFieldManager Set(int set){
            HorizontalFieldManager hr1=new HorizontalFieldManager(FIELD_HCENTER);
    
            RichTextField set1 = new RichTextField("SET " + set + ":"){
                protected void layout(int width, int height)
                {
                    super.layout(75,30);//Width and height according to the button name;
                    setExtent(75,30);//width and height according to the button name;
                }
            };
            set1.setPadding(10, 5, 10, 10);
            TextBoxField set1W = new TextBoxField(40,25);
            set1W.setPadding(10, 5, 10, 0);
            TextBoxField set1R = new TextBoxField(40,25);
            set1R.setPadding(10, 5, 10, 0);
    
            hr1.add(set1);
            hr1.add(set1W);
            hr1.add(set1R);
    
            return hr1;
        }
    

    Now in my main class I call this function to add a 'Set' on the screen using:

    add(Set(1));
    

    For the creation of the 'Set' function instead of using the instance of the textbox class in the main class itself, it is because I will create several 'sets '.

    Now, as you can see, there is a public String getText() function in the TextBoxField() that returns the value of the editField. What I need to do, is to get the value in this field, once you press a button.

    I have the code for the function button, so this isn't a matter of concern. However I do not know how to retrieve the editField value when the button is pressed. I can get the value inside the Set()function, using the:

    String getval = set1W.getText();
    

    but can't reach it from the outside. I don't even know if it's possible in the first. If it is not could someone suggest a way where I could retrieve these values.

    Any help is appreciated.

    Thank you.

    Thanks for the suggestion. I found another workaround solution. Essentially implementation of an array of TextBoxFields and then pass them one by one the "Set()" method

    I tried this at the start before posting here, but due to a careless mistake when you declare the array of TextBoxFields, I couldn't make it work.

    In any case, the topic can be closed now, because the problem has been resolved. Thank you.

  • pushScreen does not not when calling another method of another class

    Hi all

    Earlier today, I was able to get a program that is running and I was actually pretty happy with it despite the fact that he has a lot of bugs.  However, in attempting to remove bugs and me being stupid and forget to backup my previous code that it no longer works. In any case the line of code that I used was

    UiApplication.getUiApplication () .pushScreen (ScanScreen ());

    ScanScreen is a method that I created in another class.

    Any help is greatly appreciated thanks!

    Thanks for all the help!  I just made a new button and pushed the event from there.  He works for now so thank you again for all the help everyone!

  • How to get the menuitem created in another class

    Hello

    I created a class. on the inside I added a few menus using addMenuItem (Map);

    final class UserInterfaceTouch extends MainScreen
    {
    
     UserInterfaceTouch() {
            super();
    
            LabelField title = new LabelField("Nutiteq SDK Map Sample",
                    LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    
            setTitle(title);
            addMenuItem(_test);
    
        }
    MenuItem _otest = new MenuItem("Testing, 10, 10) {
            public void run() {
                --- code for doing some thing
            }
        };
    }
    

    How do I acess the menu in the class thus form another class, is it possible to do so.

    Thank you

    SujithRavindran

    Sorry for posting this.

    I got the answer.

  • Tried to copy a data disk to another disk using Power2Go received message Power2Go has stopped working any suggestions?

    Tried to copy a data file to another drive using Power2Go disc.  Received message that Power2Go has stopped working any suggestions.  I tried to uninsall the CyberLink program and reinstall from Recovery manager.  I have a HP with Windows 7 Home Edition computer.

    Hello

    1. were you able to burn the disc before using this software?

    2. you remember to make changes to the computer before this problem?

    3. are you able to burn the disc using Windows Media Player?

    Look for error messages in the event viewer for detailed error information.

    Open event viewer

    http://Windows.Microsoft.com/en-us/Windows7/open-Event-Viewer

    What are the information contained in the logs of the event (Event Viewer)?

    http://Windows.Microsoft.com/en-us/Windows7/what-information-appears-in-event-logs-Event-Viewer

    Follow these methods.

    Method 1: Check to see if you can burn the disc using Windows Explorer

    Burn a CD or DVD in Windows Explorer

    http://Windows.Microsoft.com/en-us/Windows7/burn-a-CD-or-DVD-in-Windows-Explorer

     

     

    Method 2: You can perform a clean boot that allows to check if other services third party is causing a problem.
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135
    Please note: after troubleshooting, make sure you start the computer to a normal startup mode.

  • Move the VM from one data center to another domain controller

    Hi all

    I have a machine virtual Windows 2008 R2 64-bit with 2 GB of 32 disks each and I need to migrate from one data center to another data center. Everything can agree with the approach on this movement of server? Thanks in advance.

    Summary: -.

    Source VC1-VM

    Target the VC2:-need to migrate to VC2

    Thank you

    vm2014

    As you move between two different vCenters, you can export the VM as OVF and then import them into the second vCenter.

  • Refresh JComboBox in one class when a changes JList in another class?

    Hello
    I have a small program where I am trying to update a JComboxBox in my class Main.java (a JFrame) when the contents of a JList change in another class JFrame, ProjectManager.java

    I have three classes involved in the present.

    Main
    Poster of the JComboBox

    ProjectManager
    Displays the JList and here you can add/remove items in the JList
    When this happens I want changes to be reflected in the main class

    ProfileManager
    The above two classes get their datamodel of this class by calling the static methods:
    public static ListModel getProfileListModel()
    and
    public static ComboBoxModel getProfileComboboxModel()
    I'm new to Java/Swing and I guess I'm must write a ListDataListener who warns 'Hand' that JList has changed.
    Who update the JComboBox.

    The problem is how to do that when I have three classes involved?

    I tried to create this listener in the main class:
     class ProfileListDataListener implements ListDataListener {
    
            public void contentsChanged(ListDataEvent e) {
                getProfiles();
            }
    
            public void intervalAdded(ListDataEvent e) {
                getProfiles();
            }
    
            public void intervalRemoved(ListDataEvent e) {
                getProfiles();
            }
            
        }
    getProfiles() looks like this:
    private void getProfiles() {
    cmbProfiles.setModel(profileManager.getProfileComboboxModel());
    }
    I can't add this listener to the ListDataModel since my class of earphone is not static, and if I do static, I can't call the method not static getProfiles().

    Anyway, my question is, what is the right way to do it when I want to notify a listener in the main class of class ProjectManager?

    Thank you.

    There are several ways (and I hope at least one is correct)
    You tell us how you want to update the drop-down list.
    I guess it must reflect the content of the JList. Yet,.
    I will describe the General.

    1)
    -you create hand declaring the combo as a global variable
    -you create ProjectManager by passing a reference to hand
    -join a listener JList of ProjectManager
    When the listener fires, you have access to the drop-down list via the reference of hand and the update.

    1A)
    Rather than attach the listener to the JList, you can attach it to its model,
    that might be in ProfileManager. In this case ProfileManager should have the
    the reference to hand. -By the way: you have several instances of hand or ProjectManager?
    I do not see the need for static methods in ProfileManager yet.

    2)
    -you create hand
    -you create an instance of the ProjectManager and ProjectManager must declare his
    JList as a global variable
    -You can access this list via the instance of ProjectManager
    -join a listener this list in hand and update the drop when the
    lights of the listener.

    2A)
    Rather than attach the listener to the JList, you can attach it to its model,
    that might be in ProfileManager. In the main case must have a reference to
    ProfileManager.

    I personally prefer to have the Jlist and its auditor in the same class.
    And if my assumption is right that the combo should reflect the content of the JList,
    There is no need of the ProfileManager class if his job is only to define models of
    the JList and the JCombobox.

  • instantiate a class via an argument to constructor of another class.

    public void LevelManager (owner: Home)

    {

    _owner = owner;

    }

    In my LevelManager class, I have the code above in the constructor. The House is another class that is not instantiated anywhere with the new keyword. It is simply a parameter in the constructor and then past in the body and assigned to a local variable. I didn't know that you could instantiate a class through a function parameter. Is this true?

    Congratulations in advance.

    This code is not instantiate the reception class. This code assumes that when you instantiate LevelManager, you pass an instance of the House.

    This class does not create an instance but store the reference to an instance created elsewhere except in cases when the null value is passed.

  • Calling functions from another class

    How one accesses a function from another class?

    Let's say I have a file called .as hand. My flash file uses this as this is the main class to make it work when you test the program. Let's say I have another class named Test that looks like this:

    package

    {

    public class Test

    {

    public void Test()

    {

    trace ("why don't you work?');

    }

    }

    }

    I want call the Test function when the game takes place (in the appellant to hand), how would he enter the main run file? I imported to it, made sure that the functions were public/static, created as a variable and it still doesn't work.

    Any help would be good

    the constructor for a class is different from a 'normal' function

    If you can't do something like

    meow: Test of var = new Meow();

    To call it thus:

    test: Test of var = new Test();

    test. Meow();

  • Preserving the persistence of application class id

    Hello

    I was suggested by Adobe to keep anchor persistence class id dividing the project model and ui plugin for CS5 CS4 or to give the provider of conversion if persitant format ge data has changed. But I what to do if a class that is associated with user interface is conataing doubt this implementation. Since then, this boss class, including aggregated interfaces and implementations is moved to pluging UI which will undergo a new application based on the new plugin id prefix id of the UI plugin.

    So, how we can handle this case.

    Thank you very much!

    Thanks agin for your time...!

    Will this work?

    AddIn

    {

    kMyRevisionPrefPanelDialogBoss,

    kInvalidClass,

    {

    IID_ITABLECELLDATA, kMyRevisionTableCellDataImpl,

    }

    },

    Class

    {

    kMyRevisionPrefPanelDialogBoss,

    kPrimaryResourcePanelWidgetBoss,

    {

    IID_IPANELCREATOR, kMyRevisionPrfPanelCreatorImpl,

    IID_IK2SERVICEPROVIDER, kDialogPanelServiceImpl,

    IID_IDIALOGCONTROLLER, kMyRevisionPrefPanelControllerImpl,

    IID_IOBSERVER, kMyRevisionPrefPanelObserverImpl,

    }

    },

Maybe you are looking for