WP10 NoSuchMethodError

14 views
Skip to first unread message

Bryan Buchanan

unread,
Jul 8, 2016, 6:31:49 PM7/8/16
to CodenameOne Discussions
When clicking the button with this code get attached error. Works fine on Android and simulator.

       Button b1 = new Button("Update Order");
        b1
.addActionListener(new ActionListener() {

           
@Override
           
public void actionPerformed(ActionEvent evt) {
               
if (textfield.getText().equals("")) {
                   
ToastBar.showErrorMessage("You need to enter a Quantity !");
                    textfield
.setUIID("TextFieldError");
                   
return;
               
}
               
Part part = CommonContext.INSTANCE.getCurrent();

               
int q;
               
try {
                    q
= Integer.parseInt(textfield.getText());
               
} catch (NumberFormatException ex) {
                    q
= 0;
               
}
               
if (q > part.getQty()) {
                   
ToastBar.showErrorMessage("Sorry, there are only " + part.getQty() + " available !");
                    textfield
.setUIID("TextFieldError");
                   
return;
               
}
                textfield
.setUIID("TextField");

               
boolean found = false;
               
for (Part check : CommonContext.INSTANCE.getOrderModel()) {
                   
if (check.getKey().equalsIgnoreCase(part.getKey())) {
                       
if (q > 0) {
                            check
.setQty(q);
                       
} else {
                           
CommonContext.INSTANCE.getOrderModel().remove(check);
                       
}
                        found
= true;
                       
break;
                   
}
               
}
               
if (!found) {
                   
/**
                     * didn't exists so add a new one
                     */

                    part
.setQty(q);
                   
CommonContext.INSTANCE.getOrderModel().add(Part.copy(part));
               
}
               
ViewCartForm viewcart = new ViewCartForm().init();
                viewcart
.setBackForm(backform.getBackForm());
                viewcart
.show();
           
}

       
});



wp_ss_20160709_0002.png

Shai Almog

unread,
Jul 9, 2016, 12:58:10 AM7/9/16
to CodenameOne Discussions
Odd.
Reply all
Reply to author
Forward
0 new messages