如何更改检票口中单选组的默认选择值

How to change the default selected value for the radio group in wicket

我的应用程序中有一个单选组,我必须更改单选按钮的默认选择值,我们如何在 wicket 中做到这一点?

<wicket:container wicket:id="sign in">
                        <div class="col-25">
                            <label class="radio-inline"> <input
                                wicket:id="signInYes" type="radio" name="ticker" checked="checked"  />Yes
                            </label>
                        </div>
                        <div class="col-25">
                            <label class="radio-inline"> <input
                                wicket:id="signInNo" type="radio" name="ticker" />No
                            </label>
                        </div>

                    </wicket:container>

所有 FormComponent 都将其模型对象用作 selected value。您可以在传递给构造函数的 IModel 中提供值,例如RadioChoice(String id, IModel<T> model, List<? extends T> choices)RadioGroup(String id, IModel<T> model).

你也可以在用formComponent.setModel(aNewModel)formComponent.setModelObject(aNewModelObject)

实例化后传递它

在你的情况下,我认为你使用了 RadioGroup 和 Radio 组件。所以RadioGroup的模型对象必须和应该选择的Radio的模型对象有相同的值。