Skip to main content

How to get a form or dialog instance programatically?

2 replies [Last post]
68060
Offline
Joined: 2011-08-29
Points: 0

I want to get an instance of a form or dialog (that was made in the 1.5 editor) programatically - I see no getForm() or getDialog() ? how would I do this? I dont want to show it first, otherwise I could do Form f= showForm("blah",null); - that would get me the instance but then its been shown, how do I get them without using showForm?

OK I found an explicit method for this in StateMachineBase but it still returns null when I call it:

Dialog dialog = parent.findVehicleXDetails(f);

Any ideas why?

- StatemachineBase contains:

public com.sun.lwuit.Dialog findVehicleXDetails(Container root) {
return (com.sun.lwuit.Dialog)findByName("VehicleXDetails", root);
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

The bug is that the method was generated.

There is only one form in memory which is the currently showing form (Display.getInstance().getCurrent()). The other forms just don't exist and are discarded from RAM the moment we navigate out of them so getting their instance would be irrelevant.

You can create an instance of any form or dialog using the createContainer() method, but that instance will be a different instance from the one you navigate to later on. You can show any form or diaog using showForm() which is probably better than using createContainer since it maintains the navigation stack.

You need to rethink why you need that instance, you need to place your data into the form in its beforeShow method hence avoiding potential memory leaks from accessing and modifying instances that are unnnecessary at a particular time.

68060
Offline
Joined: 2011-08-29
Points: 0

anyone? kind of need an answer fast - this seems like a blatent bug though :-( unless im doing something wrong!!