I'm sure i've missed something, but please consider the example below.
As you can see, i am adding two Long values to the radiogroup, and initializing it with a value.
However, when i try to get a long value back out it, it doesn't work because the value has become an Int!
It works if i have clicked on something in the radiogroup, but not if i get it out in its initial state.
I got around it by putting Stringvalues in the box, and doing String.parseLong, but i'm curious why this is.
Some input would be interesting. Cheers
As you can see, i am adding two Long values to the radiogroup, and initializing it with a value.
However, when i try to get a long value back out it, it doesn't work because the value has become an Int!
It works if i have clicked on something in the radiogroup, but not if i get it out in its initial state.
I got around it by putting Stringvalues in the box, and doing String.parseLong, but i'm curious why this is.
Some input would be interesting. Cheers
Code:
public void onModuleLoad(){
Button button = new Button("Check value");
RadioGroupItem filterType = new RadioGroupItem("type", "Select the thingy");
filterType.setVertical(false);
filterType.setTitleOrientation(TOP);
Map vals = new HashMap<>();
vals.put(1L, "The first value");
vals.put(2L, "The second value");
filterType.setValueMap(vals);
filterType.setValue(1L);
DynamicForm form = new DynamicForm();
form.setItems(filterType);
button.addClickHandler(clickEvent -> {
try {
Long val = (Long) filterType.getValue();
SC.say("The value is: " + val);
} catch (Exception e) {
SC.say("Error, because the value returned is not a Long, but a " +filterType.getValue().getClass().getName());
}
});
Layout l = new VLayout();
l.addMember(form);
l.addMember(button);
l.draw();
}
Comment