Showing a Dialog in handleErrorResponseCode causes a EDT violation but not in addResponseCodeListener

39 views
Skip to first unread message

cubiq1

unread,
Sep 29, 2014, 4:40:45 AM9/29/14
to codenameone...@googlegroups.com
Hi there,

Why is it when I show an error Dialog in ConnectionRequest's handleErrorResponseCode method I get an EDT violation whereas when I add a response code listener to the ConnectionRequest and show the Dialog there, things are fine?

For example, EDT violation:

        // When HTTP response received (not 200 OK or redirect)
       
@Override
       
protected void handleErrorResponseCode(int code, String message) {

           
// Show dialog -> EDT violation
           
Dialog.show("Error", "Code: " + code, "OK", null);
       
}

No EDT violation:

       
// When HTTP response received (not 200 OK or redirect)
        r
.addResponseCodeListener(new ActionListener() {

           
public void actionPerformed(ActionEvent evt) {

               
NetworkEvent n = (NetworkEvent) evt;

               
// Show dialog -> No EDT violation
               
Dialog.show("Error", "Code: " + n.getResponseCode(), "OK", null);

           
}
       
});

Thanks

Shai Almog

unread,
Sep 29, 2014, 8:04:07 AM9/29/14
to codenameone...@googlegroups.com
Hi,
all web callback methods are made on the network thread except for postResponse(). So showing a dialog is illegal.
Listeners are always normallized to the EDT.

cubiq1

unread,
Sep 29, 2014, 9:55:11 AM9/29/14
to codenameone...@googlegroups.com
Hi, thanks for the explanation. It makes perfect sense.
Reply all
Reply to author
Forward
0 new messages