Skip to main content

LWUIT code breaks randomly - why?

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

Sometimes all is working well then suddenly the code breaks and a method isnt found, there is a cryptic comment supplied by lwuit itself so this one cant be hard to figure but i dont do anything to cause it!!!

protected boolean onCUSTOMERLICAddNewAndEditDeleteSave() {
// If the resource file changes the names of components this call will break notifying you that you should fix the code
boolean val = super.onCUSTOMERLICAddNewAndEditDeleteSave(); <-- this suddenly doesnt exist!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
68060
Offline
Joined: 2011-08-29
Points: 0

this one is really killing me i cant get it to work now, even when i change the names etc!!!

OK - hair was torn, forms were renamed, buttons were deleted and recreated and its working now, there should be a simple button that regenerates everything for you and ensures it wont breal the code weirdly.. but atleast it works now!!

I cant blame lwuit editor its new and must be a real pain to develop! I still love it..

vprise
Offline
Joined: 2003-11-07
Points: 0

Save always regenerates the code for the StateMachineBase class, so we do have a regenerate button.

The comment is my usual phrasing which I deem simple and pretty much everytone else deems cryptic... Probably my bad, if you have a suggestion I would be happy to clarify the comment.

The gist of this is like that:

The resource editor always regenerates the StateMachineBase class. Within it we have callback methods matching the names of every single component you have in the GUI builder but without the spaces.

The super call is effectively redundant, it doesn't really do anything but the @Override annotation isn't supported by J2ME so it serves the same purpose. If you rename a component/form the name of the base class method changes, so effectively this method won't be called and you wouldn't get any error or indication. The super method is meant to fail in that case and alert you that this method will no longer work.

I think this approach is relatively "simple" since it cleanly separates the code that the GUI builder generates and the code you write. The main problem is getting used to the concepts and refining the rough spots within the tool.

The workaround is rather simple:

Go back to the component in the GUI builder and press the event generation button, a new method should be generated with the proper signature and you can just move your code from the old method to the new.