Lukas Hasik's notes about work life (and more)

XML

Subscribe to Lukas Hasik's Weblog on your cell phone Powered by Technorati

Let's have a ride
« December 2009
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today


Today's Page Hits: 1881

my.netbeans.org

News in pictures


the links



Recent Entries

Lukas Hasik's Weblog
All recent entries

Licence Info

This work is licensed under a Creative Commons License
LICENCE

Map of visitors

Locations of visitors to this page
Listed on BlogShares


20051101 Tuesday November 01, 2005
Change in API of SimpleCancellableTask MobilityPack

There is new WaitScreen component in Mobility Pack 5.0. You can use it for a task that usually takes lot of time (like connectiong to server) and can either succes or fail. It used Runnable and it failed when a RuntimeException appeared. We discovered that it doesn't fit to all users. The task doesn't fail when any exception appeared. Look at the code.
   
simpleCancellableTask1 = new org.netbeans.microedition.util.SimpleCancellableTask();   
simpleCancellableTask1.setRunnable(new Runnable() {
        public void run() {
                    try {
                        //some code here
                    } catch (java.io.IOException ioe) {
                        throw new RuntimeException(ioe.getMessage());
                    }
                }
        });
Isn't it strange? You catch an exception and throw new RuntimeException. Why? It should be simplier.
This is the reason why we decided to change the API of SimpleCancellableTask
simpleCancellableTask1 = new org.netbeans.microedition.util.SimpleCancellableTask();
simpleCancellableTask1.setExecutable(new org.netbeans.microedition.util.Executable() {
                public void execute() throws Exception {
                    //your code here
                }
            });
Note that any exception can be thrown in this second snip of code and when an exception appears then the task fails. That's exactly what you'd expect, wouldn't you?

Important note:
  • if you have an simpleCancellableTask from previous 5.0 build (beta or a build before 11/01) then it will be automaticaly regenerated to new syntax after a change in your Visual MIDlet.
  • f you wrote a call to the setRunnable method by hand then you have to change it to setExecutable.



Comments [3] ( Nov 01 2005, 06:30:31 PM CET ) Permalink del.icio.us furl simpy slashdot technorati digg

Trackback URL: http://blogs.sun.com/lukas/entry/change_in_waitscreen_component
Comments:

I usually use public void execute() throws Throwable { instead so I don't have to wrap everything in Exceptions.

Posted by Matthew Ford on November 04, 2005 at 01:03 AM CET #

<b>org.netbeans.microedition.util</b>
<br>
where can if find the Library/package of this Class

Posted by sherwin corpuz on August 14, 2008 at 04:09 AM CEST #

I have a problem with this,
i am calling waiting screen and in turn Task
on the action event of a button

//CODE
switchDisplayable(null, getWaitScreen());
//CODE OVER

but now when i cancel back to the same form and even i have made waitScreen and Task as null,
now if i perform action Event
task is not getting exweecuted.......

Posted by Jigar on July 28, 2009 at 03:33 PM CEST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed


Disclaimer: The contents of my blog represent my personal opinions which may differ from official views of my employer, Sun Microsystems.