本文整理汇总了Java中org.apache.wicket.extensions.model.AbstractCheckBoxModel类的典型用法代码示例。如果您正苦于以下问题:Java AbstractCheckBoxModel类的具体用法?Java AbstractCheckBoxModel怎么用?Java AbstractCheckBoxModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractCheckBoxModel类属于org.apache.wicket.extensions.model包,在下文中一共展示了AbstractCheckBoxModel类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newCheckBox
import org.apache.wicket.extensions.model.AbstractCheckBoxModel; //导入依赖的package包/类
protected CheckBox newCheckBox(String id, final IModel<Boolean> checkModel) {
final CheckBox checkBox = new CheckBox("check", checkModel) {
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
if (checkModel.getObject() != null) {
tag.append("class", uuid, " ");
}
}
};
if (checkModel.getObject() != null) { // checkModel is null for the "select all" checkbox in the column header
checkBox.add(new ClickAjaxEventBehavior<Boolean>(checkModel) {
protected void onEvent(AjaxRequestTarget target, IModel<Boolean> model) {
AbstractCheckBoxModel m = (AbstractCheckBoxModel) model;
if (m.isSelected()) {
m.unselect();
} else {
m.select();
}
target.add(checkBox);
}
});
}
return checkBox;
}
示例2: newCheckBoxModel
import org.apache.wicket.extensions.model.AbstractCheckBoxModel; //导入依赖的package包/类
@Override
protected IModel<Boolean> newCheckBoxModel(final IModel<T> rowModel) {
return new AbstractCheckBoxModel() {
private static final long serialVersionUID = 1L;
@Override
public boolean isSelected() {
return selected.contains(rowModel.getObject());
}
@Override
public void unselect() {
selected.remove(rowModel.getObject());
}
@Override
public void select() {
selected.add(rowModel.getObject());
}
@Override
public void detach() {
rowModel.detach();
}
};
}
示例3: buildEditor
import org.apache.wicket.extensions.model.AbstractCheckBoxModel; //导入依赖的package包/类
@Override
public void buildEditor(PanelContainer popup) {
LabelledPanel labelledPanel = new LabelledPanel(popup.newPanelId());
popup.addPanel(labelledPanel);
labelledPanel.setLabel(getName());
CheckBoxContainerPanel checkBoxContainer = new CheckBoxContainerPanel(labelledPanel.newPanelId());
labelledPanel.addPanel(checkBoxContainer);
checkBoxContainer.setMinSelections(1, Model.of("Please make at least one selection."));
for (final E value : enumClass.getEnumConstants()) {
if (isVisible(value)) {
IModel<Boolean> model = new AbstractCheckBoxModel() {
@Override
public boolean isSelected() {
return selectedValues.contains(value);
}
@Override
public void select() {
if (!isSelected()) {
selectedValues.add(value);
}
}
@Override
public void unselect() {
if (isSelected()) {
selectedValues.remove(value);
}
}
};
checkBoxContainer.addPanel(new CheckBoxPanel(checkBoxContainer.newPanelId(), model)
.setLabel(EnumUtils.toString(value)));
}
}
}