Build a class variable value

Hello

I am trying to initialize a class based on the value of a variable. I know that I can use the class of thinking in Java, but J2ME does not support this.  Is there another way?

To give you an idea of what I'm trying to do, I have a main object (UiApplication) passed to all initialized screens. Now this main object has a method named getScreenInstance() that can be called by any screen to get an instance of a screen based on the string, they put in the parameter.

The point of this is so I can push to another screen at any time without having to re - initialize it if it is already initialized. This might be able to do differently, I am new to J2ME (and kinda new to Java as well).

If there is a different way, I'd like the solution, although always, I would like to know if it is possible dynamicalled load a class and pass parameters to the constructor it is also.

Thanks in advance

Apart from the ugliness, what's not with something like:

public Screen getScreenInstance( String screen_name ) {
  Screen screen = (Screen) this.screen_registry.get( screen_name );
  if ( screen == null ) {
    screen = makeScreen( screen_name );
    if (screen != null) {
      screen_registry.put( screen_name, screen );
    } else {
      // report unrecognized screen name
    }
  }
  return screen;
}

private Screen makeScreen( String screen_name ) {
  if ( "ScreenA".equals(screen_name) ) return new ScreenA(this);
  if ( "ScreenB".equals(screen_name) ) return new ScreenB(this);
  // etc.
  return null; // unrecognized name
}

You might even be able to do something with initializers static in the classes of your screen so that the names of class is part of a register before that all instances must be created (although this puts you at the mercy of the arcana of class loaders machinery).

Tags: BlackBerry Developers

Similar Questions

  • HTTPService data object / class variable number

    Hello

    I am building a Flex application with ActionScript classes where the class contains all events management. In a class like:

    {stuff package
    public var xml:XML() = new XML();
    public void MyObject() {}
    public void getData (): void {}
    Here I create an HTTPService object, fill in all the information and send it.
    }
    public void resultHandler(event:ResultEvent):void {}
    XML = XML (event.result);
    I get the XML very well here, but after the end of this call, I can't get this data more
    }
    error handler, etc.
    }


    The problem is that if I want to view/use these data in the result handler, that is fine, but if I try to store these data in a class variable, I can't recover this data from outside the class. If I refer to this object to another object, the data, all right and I can see the xml from the results Manager, but I can't seem to store these data, then pull it out via a class variable, or via a getter method that returns the variable. Is there something I'm missing here? Basically, I want to get the information via the HTTPService and store this information in a class variable that I can access it later. How can I do this?

    Thank you.

    Thanks for all your suggestions. The final problem was indeed the asynchronous nature of data calls HTTPService. I found a series of articles that has highlighted and provided solutions to the issue. An important quote from one of the articles is: "the fact that the web service calls flex are asynchronous have implications on how you design your code." and even, "the asynchronicity of remote calls has a major impact on how you design the customer."

    This is exactly the kind of information was missing and I have not found well-described in the Adobe Flex 3 documentation or tutorials I've read.

    Here are some links to more useful articles I found:
    http://tinyurl.com/34py5p
    http://techpolesen.blogspot.com/2007/09/coping-with-Flex-asynchronous-remote.html
    http://techpolesen.blogspot.com/2007/09/coping-with-Flex-asynchronous-remote_26.html
    http://techpolesen.blogspot.com/2007/11/coping-with-Flex-asynchronous-remote.html

  • How to pass a variable value into a hyperlink?

    Hello

    I put a variable value by using <? xdoxslt:set_variable ($_XDOCTX, 'tstview', concat ((xdoxslt:get_variable($_XDOCTX,'env_url')), (xdoxslt:get_variable($_XDOCTX,_'testpage')))? >)
    I am able to the value of the variable is displayed correctly. I would use this value to create a hyperlink by specifying {$tstview} {ID} in the text of the hyperlink box. However, when I do that, I get the error message: Undefined Variable: "tstview."

    How can I pass the value of the variable to create a hyperlink? Is there another way to do this? I want to be able to build the hyperlink in a dynamic way. Please let me know.

    Thank you!!
    
    

    or try

    {xdoxslt:get_variable($_XDOCTX,'env_url')}{ID}
    
  • Why can I not use Get LV class Default Value in a dynamic VI?

    I'm trying to substitute a VI that uses 'Get default class LV value' and get an error that I do not understand.  My parent, 'Message class of ANT' class, has two children - "Class ANT from the command" and "ANT-class response.  Children participate a lot of data and features, including the factory pattern that implements 'Load Message class' VI of the superclass (see image).  I would replace this VI with a version of command and a version of the response, which would simply call the version of the Message with their respective classes of the substitution of dynamic input and output terminals.  However, I get the error "Front Panel"ANT Out class Message"Terminal: type of execution do not spread of dynamic input to dynamic output.»

    Don't know how to get around it.  Any ideas?

    Thank you

    -Jamie

    That sounds like a strange thing to do - what you will do is to return the default value for the entry class. What is the reason for the class loader of the disc? You SHOULD have already loaded the class in memory, because the output type MUST be the same as the input type (this is a requirement of dynamic distribution work, because the error is telling you). Since you already have the class that is loaded in memory, there is an easier way to get the default value: wiring a loop For iteration 0, and the entry class through wire directly to the output class, with tunnels on the inputs and outputs (NOT shift registers). As the loop never executes, the output is the default value for this class (see https://lavag.org/topic/15354-testing-for-the-same-class/#entry92502).

    Replace "to more specific class" with "class of Run-Time to preserve" will also work, but still, I can't understand why you try to do it at all.

  • change the settings of the view variable value

    Hello

    I want to know if it is possible to change the settings for the debugger, including the display of the "view variable values" settings in labwindows cvi 9.0.

    My problem is that in my project, it is essential to be able to debug and I came across some difficulities with the array of structs containing pointers to structures. So, I did a demonstration to show project:

    typedef struct {}
    short sVar1;
    short sVar2;
    char cVar1 [512];
    } MyStruct2;

    typedef struct {}
    MyStruct2 ReadMyS2;
    MyStruct2 WriteMyS2;
    MyStruct2 * pReadMyS2;
    MyStruct2 * pWriteMyS2;
    } MyStruct1;

    int main()

    {

    MyStruct1 MyS1_Phis [3] = {0};
    int i = 0;

    init
     
    for (i = 0; i<>
    {

    MyS1_Phis [i] .pReadMyS2 = & MyS1_Phis [i]. ReadMyS2;

    MyS1_Phis [i] .pWriteMyS2 = & MyS1_Phis [i]. WriteMyS2;
    }

    }

    Unfortunately, the debugger handles .pReadMyS2 pointer [0] MyS1_Phis as if that it points to an array of 10 elements of type MyStruct2.

    Anyone know the reason for this?

    Thanks in advance,

    Laszlo Nagy

    Hi Laszlo,

    Yes, it is a known problem in CVI. This can happen because of the way the CVI user protection is implemented. It is certainly not desirable, but we probably won't be able to change it at least still a year or two.

    A solution you have is to disable the protection of the user and then rebuild your program (Options > Compiler Options > level debugging: no execution check)

    Luis

  • programmatically set the bind view variable value of object that showed to the query Panel

    Hello

    I have a case in 11.1.1.7 Jdev, I deploy my application on BPM 11.1.1.7.

    I have a VO that three attributes of it was put in a viewcriteria... Let's attribute A1, A2, and A3. the view criteria is any condition "AND".

    and then I create a variable binding in the VO named b. my vo also query using this variable B.

    in the jspx, I create a query panel based on the viewcriteria. then in the A1, A2, A3 and B query pane shows.

    I can reset the Panel request programmatically using this tutorial http://www.jobinesh.com/2011/04/programmatically-resetting-and-search.html

    but unfortunately he didn't succeed for A1, A2, A3 because they are in the display criteria, but B can't reset.

    I tried to put the value programmatically using queryModel, queryDescriptor, setNamedWhereClauseParam, but this failed and it starts to makes me crazy...

    anyone here seen cases like me? and found the workaround? pls throw some light.

    Thank you

    Have you tried with VariableValueManager? http://www.jobinesh.com/2010/10/how-to-set-bind-variable-values-at.html

    Dario

  • How access an item by using its name or id if this isn't a class variable?

    I'm recovering the item that I added to my user interface in a different function. I use actionscript 3. I know that I can put the variable in a class variable, so it can be access anywhere in the class, but I have too many items. Is there anyway that I could access it without putting them in the class variable?

    Thank you.

    public class Test extends SkinnableContainer{
    
    // private var image:Image; <-- I try not to do this, too messy
    
    private function func1() {
        var image:Image = new Image();
        addElement(image);
    }
    
    
    private function func2() {
        var image:Image = /* how to get the element from my UI without putting into class variable */
    }
    

    Of course, because you don't want to create in the first place of the variables

    But you could add one to a dictionary of class and get your references from there.

    Something like this:

    private var objArray:Dictionary = new Dictionary();
    private function init (): void
    {
    var image: Image = new Image();
    ObjArr ['image'] = addElement (image);
    trace (gridArray ['image']);
    }

  • How to access the static class variable calendar / singleton?

    How can I access a timeline of a static class variable / singleton?

    You can pass any object to display list to your class when instantiating it.  all objects in the display list has a placement property that allows access to the stage and them you can use the correct path/name to your variable.

  • LV2010 build request: error 1498 for LV class default Value.vi

    I am creating an application (exe) with LabVIEW 2010 Professional Development System SP1 (32-bit) file. The operating system is Windows 7 Professional (64 bit). Unfortunately I get this error when I click on "build specifications/New/Application (EXE):"

    Here is the full error message

    Possible reasons:

    LabVIEW: Library has errors. Correct the errors before performing this operation.

    «"" "String of full appeal:»»"»
    Download LV class by default Value.vi
    AB_UI_Initialize_Framework.VI
    AB_UI_FRAMEWORK.VI
    AB_CreateNewWizard_Invoke_CORE.VI

    EBUIP_CreateNewWizard_Invoke.VI
    EBUIP_CreateNewWizard_Invoke.VI.ProxyCaller

    LabVIEW has tried to load the class in this path:
    C:\Program Files (x 86) \National Instruments\LabVIEW 2010\vi.lib\AppBuilder\AB_Classes\Build\UI\AB_UI_Frmwk_Build.lvclass

    The file is definitely available.

    Well, this is also the code :-)

    Do you know what happens? I guess that one cannot not so complicated to create an executable file. I'm doing something wrong?

    Thank you, Nick

    Hmmm you could try doing a repair of LabVIEW. Go to start > Control Panel > add and remove programs > National Instruments > modify (repair) LabVIEW. This will go through and make sure it has the correct paths to the request of the manufacturer. Let me know if it works

  • Build error [class bad file]

    Hi all

    I try to compile Hyperic HQ 3.0.4 by Eclipse 3.2 on Windows XP.
    I went through the training to build.
    But during construction, I got an error as follows.
    Isn't good CLASSPATH?
    I don't know how to do to investigate this matter.
    If you could give me some advice about this, please help me.

    > compilation-app-sources:
    > [javac] 2557 compilation of source D:\Workspace\HQ3\build\classes files
    > [javac] D:\Workspace\HQ3\build\src\org\hyperic\hq\autoinventory\shared\AutoinventoryManagerHome.java:109: cannot access org.hyperic.hq.autoinventory.shared.AutoinventoryManager
    > bad class file [javac]: D:\Workspace\HQ3\build\src\org\hyperic\hq\autoinventory\shared\AutoinventoryManager.java
    > [javac] file contains no class org.hyperic.hq.autoinventory.shared.AutoinventoryManager
    > [javac] if please remove or make sure it appears in the correct subdirectory of the classpath variable.
    > [javac] public org.hyperic.hq.autoinventory.shared.AutoinventoryManager create()
    > [javac] ^.
    > [javac] error 1
    >
    > BUILD FAILED

    Kind regards
    mtbtaizo

    Ah yes, you use the 3.0.5. tar.gz rather than subversion?  If you want just the update build.xml, you can retrieve it here:

    http://svn.Hyperic.org/branches/HQ_3_0/build.XML?root=Hyperic+HQ&revision=4842&content-type=text%2Fplain&pathrev=4842

    Beta 3.1 includes this change also.

  • vs 10g 11g: VO bind variable values stale on jbo.ampool.doampooling = false

    Hi gang

    (JDev 11g Build 5188)

    I'm currently such tests recommended by the merger of 11g Guide to test the management of State ADF BC with jbo.ampool.doampooling = false (see paragraphs 36 and 37). I see different behaviors under 11 g vs 10 g.

    I have a single VO updateable with a query that is limited by a single binding variable. I have a JSF page with the link as command inputText variable, executeWithParams one operating control commandButton, and a table showing the results of the VO.

    Less than 10g, I can:

    (1) open the page
    (2) enter a value (say X) to the variable binding, click the executeWithParams button and correctly to see results in the table corresponding to the value of the bind variable X.
    (3) enter a different value for the binding variable (say Y), click on the executeWithParams button and correctly to see results in the table corresponding to the value of the value of the bind variable Y.

    Less than 11g I get different behaviors for # 3. Instead when I press the button executeWithParams with the value defined on, the table always show results for the previous value of the variable X bind?

    It should be noted that if I set jbo.ampool.doampooling = true, the problem goes away, but probably the error reappears in a system of production under load, so I need to find what is happening here.

    Maybe I see a bug, but given the large amount of changes 11 g and large amount of documents that I read on the management of the State, it could just be that I missed something vital to 11 g.

    Does anyone have any opinions, what is happening here?

    Thank you for your help in advance.

    CM.

    Thanks Chris - I took possession of the SR.

    Kind regards

    Didier.

  • build the table when values change at run time

    Hi all

    I have a continuous stream of frequencies that continue to change during execution. I need to make a table of these values. I use the array build function. This option stores the first value only and the order of the day replaces the stored rather than settle down after that. I was going through the examples of labview and I think that by using the shift register can somehow solve this problem. However after an hour of futile play with lag, while loop records and build blocks table that I decided to post on this problem. I would like if someone can delete my concepts as well as a solution. The conceptual linkage is for what the first value to maintains have replaced. If I use the table of generation block the values that come should then fill the following vacant location logically. Instead, it replaces one only.

    You are right that I have simply the case that I warned the first sentence.

    Other methods require a certain amount of planning on the structure of data-handling. It is suggested at least...

    A better approach would be something like a circular buffer where you initialize an array of the desired size (for example 10000 items) and then start to replace the items. You can use the iterator of the loop you have to 'reduce' using quotient & reminder (which is the 'modulo' mathematical operation).

    hope this helps,

    Norbert

  • Build an array of values of the difference

    Dear members,

    With reference to the attached LabVIEW 2010 Student Edition file...

    From the incoming data via the .csv "Reading of the spreadsheet", I want to display a picture of the difference between the n and n-1 data value if the data set is 10, 20, 25, 35, 50, then the difference will be 10, 5, 10, 15.

    I used the "Index Array" function to extract the n and n - 1 values (using the function 'Simulation' as the incrementer line index) however I can't find the way to build an array of these difference values and display them in the façade, which is

    10

    5

    10

    15

    It will probably be a trivial problem for more experienced LabVIEW programmers.  Advice or assistance is welcome.

    Kind regards

    Since you have 1 column of 800 lines, then use table to Index first to get only the first column.  This will give you a table 1 d of 800 items.  Then the idea to use this table, as well as the subset of the table for the 2nd through the remaining lines, subtract one from the other, work.

    I can't comment on the simulation loops because I don't have that and never used.

  • Keep persistent variable values

    Hi all

    I'm about to create a random coefficients (FRC) for an Adaptive order blur in LabVIEW. The original design made in MATLAB/SIMULINK and I'm trying to translate functions in LabVIEW to my creations.
    The MATLAB function is then called in Simulink and returns the results. What I'm stuck with, is how PERMANENT is kept in LabVIEW. Consider the following script:

    e = [0.2 0.3];

    current_error = e (1);
    simulation_time = e (2);

    number of persistent;
    persistent previous_error;

    If isempty (count)
    Count = 0;
    end

    If isempty (previous_error)
    previous_error = 0;
    end

    Count = count + 1;

    control_activity = (current_error + previous_error) count;

    previous_error = current_error + previous_error;

    The above script retains the values of the persistent variables (County, previous_error) intact whenever this function is called in Simulink. But in LabVIEW how it's done?
    I'll probably call the same function in LabVIEW in a main loop. Am I supposed to use the shift registers to pass values between iterations?

    It will be the variable persistence?

    There is one post of the same problem in this forum, but the guy there wants to keep intact values using the VI. I, on the other hand, want to keep my values in a jar as soon as my function is called in a loop.

    Help!

    Kind regards.

    NapDynamite wrote:

    The above script retains the values of the persistent variables (County, previous_error) intact whenever this function is called in Simulink. But in LabVIEW how it's done?
    I'll probably call the same function in LabVIEW in a main loop. Am I supposed to use the shift registers to pass values between iterations?

    It will be the variable persistence?

    Yes, using shift registers

  • Custom build package-class protection

    Hello

    I have a project that uses Ant bb tools and custom build script. Problem is that I found havn't solution how to specify for what classes and packages *. KEY file is applied. In projects created by using eclipse plugin is BlackBerry_App_Descriptor.xml containing ProtectInfo tag after selecting packages/classes in package-class Protection file editor. Building using plugin Cap reads the security descriptor information and adds it to CSL. File CSI. I do not use BlackBerry_App_Descriptor.xml in my project and then it raises the question - how store and pass information to the tool of signed on for that brother. COD to ask my own signing authority signature?

    The copy. KEY file in the directory entry for the CAP and adding its own authority ID he .csl helped me.

Maybe you are looking for

  • Messages sent from the wrong account

    I have 3 accounts gmail on T-Bird. When I send an email to an account, it goes to the recipient as if sent by one of the other accounts. two accounts of work and a private and I'm not really them mixed. Any suggestions?

  • Qosmio F50: screen all in game - driver Win 8 GPU sometimes black

    Hello I have problem with my display driver for nvidia geforce 9700M GTS on windows 8 I just installed new Windows 8. Everything works fine on my laptop but there is a big problem.Update of Windows installed new display driver for Nvidia (I think ver

  • Black screen on my Satellite M40x

    Hi guys I m new on this forum, you are looking for help with my laptop. I was using my laptop for a gd while now but 2 nite I turned on she was ok then the screen went black.The hard drive is running and that the drive to DVD, but the screen remains

  • Qosmio G10: Blue screen shot and later endless reboot

    Hello! I found similar topics on this problem, but they were locked and left unanswered. My problem is this: I have not changed of _anything_ in the BIOS for a log time. I have not installed new software or hardware lately. And I have not damaged my

  • Already activated Windows XP, by asking for activation.

    My computer says "must activate Windows to open a session. If I choose Yes it says "Windows is already activated.  If I, he goes to the log in page. When I then try to connect, he repeats the same thing.