我想在默认情况下将我的无线电选项设置为"Sim“,我如何做到这一点?
我的定制无线电选择课:
package com.sges.web.components;
import java.util.ArrayList;
import java.util.Arrays;
import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
import org.apache.wicket.markup.html.form.RadioChoice;
import org.apache.wicket.model.IModel;
public class RadioSimNao extends RadioChoice<Boolean> {
private static final long serialVersionUID = 1L;
public RadioSimNao(String id, IModel<Boolean> model) {
super(id, model, new ArrayList<Boolean>(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), new BooleanChoiceRenderer());
add(AjaxFormChoiceComponentUpdatingBehavior.onUpdateChoice(target -> target.add(getThis())));
}
private RadioSimNao getThis() {
return this;
}
}
这是我初始化的地方。
dispoeGeradoresEmergenciaChoice = new RadioSimNao("dispoeGeradoresEmergencia",null);
dispoeGeradoresEmergenciaChoice.setEnabled(false);
dimensao_enquadramento_container.add(dispoeGeradoresEmergenciaChoice);
发布于 2022-05-13 07:11:02
super(id, model, new ArrayList<Boolean>(Arrays.asList(Boolean.TRUE, Boolean.FALSE)), new BooleanChoiceRenderer());
这里您说RadioChoice可能有两个可能的值:TRUE
和FALSE
2.
dispoeGeradoresEmergenciaChoice = new RadioSimNao("dispoeGeradoresEmergencia",null);
在这里,您将null
作为所选值的模型传递。如果要预选任何可能的值,则应传递Model.of(true)
或Model.of(false)
。
还不清楚Sim
在I want to set my Radio Choice to "Sim" by default
中是什么意思。"Sim“不是可能的值(真为FALSE)。
https://stackoverflow.com/questions/72219716
复制相似问题