codenameone - ToastBar in postResponse of connectionRequest -
toastbar
when use in part of code, works fine, when use show message connection completed ie. use in postresponse
of connectionrequest
, doesn't show. why?
public boolean abc = false; connectionrequest cr = new connectionrequest(){ @override protected void postresponse() { abc = true; //update: toastbar commented toastbar.showmessage("confirmation of password sent email address", fontimage.material_mail_outline,2000); } }; cr.setpost(true); cr.seturl(allurl.forgetpasswordurl); cr.setduplicatesupported(true); cr.settimeout(30000); cr.addargument("forgetten_email", forgottonemail); infiniteprogress ip = new infiniteprogress(); dialog d = ip.showinifiniteblocking(); cr.setdisposeoncompletion(d); networkmanager.getinstance().addtoqueueandwait(cr);
update1: form created in gui builder blank dialog. toastbar doesnot work here dialog box works
protected void beforeforgetpassworddialog(form f) { textfield emailtextfield = new textfield(); f.add(emailtextfield); button submit = new button("submit"); submit.addactionlistener(e -> { style s = uimanager.getinstance().getcomponentstyle("label"); string forgottenpasswordemail = emailtextfield.gettext(); if (forgottenpasswordemail != null && !forgottenpasswordemail.equals("")) { forgetpasswordconnection fpc = new forgetpasswordconnection(); fpc.forgetpasswordconnectionmethod(forgottenpasswordemail, s, statemachine.this, f); forgetpasswordsuccess = fpc.abc; if (forgetpasswordsuccess) { showform("main", null); } } else { //dialog.show(null, "email id empty", "ok", null); //dialogbox works here, toastbar doesnt work // f.addshowlistener(d -> { // toastbar.showmessage("email id empty", fontimage.material_mail_outline, 2000); // }); } }); f.add(submit); }
notice method invoked before dialog disposed showing toastbar on dialog instead of parent form. try keeping reference current form , add show listener e.g.:
parentform.addshowlistener(e -> showmytoastbar());
Comments
Post a Comment