2017-03-22 18 views
0

RadioButtonsに関連する奇妙なケースのGWTを見つけました。私は複数のラジオから構成されたコンポーネントを作成してXと呼ぶことができます.X内のラジオはデフォルトで選択されています。しかし、このコンポーネントを1回のビューでN回使用すると、最後のXデフォルト選択でのみ動作します。 instace についてはGWTの不規則なラジオボタンの動作

のは

<g:HTMLPanel> 
    <cc:RadioButtonComponent ui:field="one"/> 
    <br/> 
    <cc:RadioButtonComponent ui:field="two"/> 

</g:HTMLPanel> 

クラス

public class AggregatorComponent extends Composite { 

    private static AggregatorComponentUiBinder uiBinder = GWT.create(AggregatorComponentUiBinder.class); 

    interface AggregatorComponentUiBinder extends UiBinder<Widget, AggregatorComponent> { 
    } 

    @UiField 
    RadioButtonComponent one; 
    @UiField 
    RadioButtonComponent two; 

    public AggregatorComponent() { 
    initWidget(uiBinder.createAndBindUi(this)); 
    } 
} 

と例RadioButtonComponentのUI

<g:HTMLPanel> 

    <g:RadioButton ui:field="radioOne" name="radioGroup"/> 
    <g:RadioButton ui:field="radioTwo" name="radioGroup"/> 
    <br/> 
    <g:CheckBox ui:field="checkBox1"/> 
</g:HTMLPanel> 

とクラス

アグリゲータUIを構築してみましょう。例として、
public class RadioButtonComponent extends Composite { 

    private static RadioButtonComponentUiBinder uiBinder = GWT.create(RadioButtonComponentUiBinder.class); 

    interface RadioButtonComponentUiBinder extends UiBinder<Widget, RadioButtonComponent> { 
    } 

    @UiField 
    RadioButton radioOne; 

    @UiField 
    RadioButton radioTwo; 

    @UiField 
    CheckBox checkBox1; 

    public RadioButtonComponent() { 
    initWidget(uiBinder.createAndBindUi(this)); 
    radioOne.setValue(true); 
    checkBox1.setValue(true); 
    } 

} 

この場合、チェックボックスはうまく機能します。

結果は次のようになります。

enter image description here

とunselecedラジオは確か
<input type="radio" name="radioGroup" value="on" id="gwt-uid-6" tabindex="0" checked="">を確認しましたが、この1怒鳴るはIDのみが異なる同じにチェック値を持ちます。

QUESTION

これはバグですか?
どのようにこの障害を克服するには? GWT 2.8のJava 8 クロームバージョン56.0.2924.87でテスト

は、FireFoxの56およびIE 11

敬具

答えて

1

ラジオボタンは、その名前に基づいてグループ化されているので、あなたは、それぞれに異なる名前を与える必要がありますグループ(1つをRadioButtonComponentに渡すか、内部にユニークなものを生成する)

関連する問題