1. #1
    Ext User
    Join Date
    Jun 2008
    Posts
    12
    Vote Rating
    0
    karthick_3d is on a distinguished road

      0  

    Default RadioGroup Internationalization

    RadioGroup Internationalization


    Hi,

    I am trying to put a RadioGroup with 2 Radio buttons in multiple languages.

    e.g. "Male" and "Female" in English
    or "m

  2. #2
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default


    Radio.getValue returns a Boolean... not sure what you mean by it returning either "Male" in english or "m

  3. #3
    Ext User
    Join Date
    Jun 2008
    Posts
    12
    Vote Rating
    0
    karthick_3d is on a distinguished road

      0  

    Default


    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

  4. #4
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default


    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....
    }

  5. #5
    Ext User
    Join Date
    Jun 2008
    Posts
    12
    Vote Rating
    0
    karthick_3d is on a distinguished road

      0  

    Default


    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

  6. #6
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default


    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...

Thread Participants: 1