Hi,
I am trying to put a RadioGroup with 2 Radio buttons in multiple languages.
e.g. "Male" and "Female" in English
or "m
Hi,
I am trying to put a RadioGroup with 2 Radio buttons in multiple languages.
e.g. "Male" and "Female" in English
or "m
Radio.getValue returns a Boolean... not sure what you mean by it returning either "Male" in english or "m
Hi gslender,
Thanks for your reply.
Let me try to explain with the example.
For the already given example, If I put a button and add a listener which calls the below statement,
Window.alert(gendField.getValue().getBoxLabel())
I will be getting "Male" if the property loaded is english or "m
why not do this?
Code:Radio maleRadio = new Radio(); maleRadio .setBoxLabel(constant.getMaleTxt()); Radio femaleRadio= new Radio(); femaleRadio.setBoxLabel(constant.getFemaleTxt()); RadioGroup gendField = new RadioGroup(); gendField.add(radio1); gendField.add(radio2); if (gendField.getValue() == maleRadio) { // do what you need with male.... }
Thanks gslender,
I would try to change my code like that.
But I am no sure if this will be useful for a generic solution (like choosing color, complexity level, etc).
The prototype of the code will look like this.
RadioGroup retField = new RadioGroup();
retField.setFieldLabel(label);
if(valueList != null && valueList.size() > 0) {
for(CodeNameModel codeNameModel: valueList) {
Radio radio = new Radio();
radio.setBoxLabel((String)codeNameModel.get(CodeNameModel.KEY_NAME));
radio.setData(CodeNameModel.KEY_CODE,
(String)codeNameModel.get(CodeNameModel.KEY_CODE));
retField.add(radio);
}
}
I thought of doing a small application as a prototype to show some of my project mates about the use of GWT & gxt. But worried to see the amount of code we write is getting larger. I am not sure how others see this? probably I am crap in writing a good code.
Regards
Karthick
there are lots of ways to do what you are trying to do - the cleanest would be (IMO) to extend Radio to MyIdRadio and add the constructor's and value fields that identify the radio button - similar to what you are doing with setting the data object, but probably cleaner looking - it would be nice if Radio used generics so you can store the label and id as part of the value - like we can do for TextField / ComboBox etc...
the nice aspect of Java is that you can easily/simply extend classes to do what you want/need etc...