jeudi 9 mars 2017

JAVA, NativeSelect wait until I choose an option

I'm using a framework named Vaadin, in it I use a NativeSelect, who works like a select HTML. And I want to setVisible(true) when one option is choose. Here my code :

List<String> behaviourData = new ArrayList<>();
 behaviourData.add(new String("end"));
 behaviourData.add(new String("end-dx6"));
 NativeSelect behaviour1 = new NativeSelect("Select", behaviourData);
 behaviour1.addValueChangeListener(event -> Notification.show("Value changed:",    String.valueOf(behaviour1.getValue()), Notification.Type.TRAY_NOTIFICATION));
if (behaviour1.getValue().equals("end-dx6")) {
    System.out.print("else if");
    hop1.setVisible(true);
    out1.setVisible(true);
    nextHop.setVisible(true);
    outGoing.setVisible(true);
 }

But when I launch my page, I have an error because behaviour1 is empty, I understand I try to surrender by try/catch but after, when I change the value of the select it doesn't enter into my if condition. Have you any idea ? Thank You.

Aucun commentaire:

Enregistrer un commentaire