Example usage for org.apache.wicket.markup.html.form Check setLabel

List of usage examples for org.apache.wicket.markup.html.form Check setLabel

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form Check setLabel.

Prototype

@Override
public Check<T> setLabel(IModel<String> labelModel) 

Source Link

Document

The value will be made available to the validator property by means of ${label}.

Usage

From source file:org.geoserver.qos.web.OperatingInfoTimeModalPanel.java

License:Open Source License

public OperatingInfoTimeModalPanel(String id, IModel<OperatingInfoTime> model,
        SerializableConsumer<OperatingInfoTime> onSave) {
    super(id, model);
    this.onSave = onSave;
    this.timesText = new TimesText(model.getObject());

    // form//from ww w  .  ja  va  2s. c  om
    final WebMarkupContainer form = new WebMarkupContainer("opInfoTimeForm");
    add(form);

    // multiselector for List<DayOfWeek>
    if (model.getObject().getDays() == null)
        model.getObject().setDays(new ArrayList<>());
    CheckGroup<DayOfWeek> daysChecks = new CheckGroup<>("daysOfWeekCheckGroup", model.getObject().getDays());
    daysChecks.setOutputMarkupId(true);
    form.add(daysChecks);
    ListView<DayOfWeek> checksList = new ListView<DayOfWeek>("days",
            new ArrayList<>(Arrays.asList(DayOfWeek.values()))) {
        @Override
        protected void populateItem(ListItem<DayOfWeek> item) {
            Check<DayOfWeek> check = new Check<>("daysCheck", item.getModel());
            check.setLabel(Model.of(item.getModel().getObject().value()));
            item.add(check);
            item.add(new SimpleFormComponentLabel("day", check));
        }
    };
    daysChecks.add(checksList);

    // calendar startTime, TextField
    final TextField<String> startTimeField = new TextField<String>("startTimeField",
            new PropertyModel<>(timesText, "startTime"));
    addTimeRegexValidator(startTimeField);
    form.add(startTimeField);

    // calendar endDate
    final TextField<String> endTimeField = new TextField<>("endTimeField",
            new PropertyModel<>(timesText, "endTime"));
    addTimeRegexValidator(endTimeField);
    form.add(endTimeField);

    final AjaxSubmitLink deleteLink = new AjaxSubmitLink("deleteLink") {
        @Override
        public void onAfterSubmit(AjaxRequestTarget target, Form<?> form) {
            onDelete(target);
        }
    };
    form.add(deleteLink);
}

From source file:org.odlabs.wiquery.ui.button.ButtonCheckSet.java

License:Open Source License

/**
 * Constructor//from ww  w  . j av a  2 s  . c o m
 * 
 * @param id
 *            Wicket identifier
 * @param checks
 *            List of checks
 * @param model
 *            Model of the default object
 */
public ButtonCheckSet(String id, IModel<? extends List<ButtonElement<T>>> checks,
        IModel<? extends Collection<T>> model) {
    super(id);

    checkGroup = new CheckGroup<T>("buttonCheckSetGroup", model) {
        private static final long serialVersionUID = 8265281439115476364L;

        @Override
        protected void onSelectionChanged(final Collection<T> newSelection) {
            ButtonCheckSet.this.onSelectionChanged(newSelection);
        }

        /**
         * This method should be overridden to return true if it is desirable to have
         * on-selection-changed notification.
         * 
         * @return true if component should receive on-selection-changed
         *         notifications, false otherwise
         */
        @Override
        protected boolean wantOnSelectionChangedNotifications() {
            return ButtonCheckSet.this.wantOnSelectionChangedNotifications();
        }
    };
    checkGroup.setOutputMarkupId(true);
    checkGroup.setRenderBodyOnly(false);
    add(checkGroup);

    ListView<? extends ButtonElement<T>> view = new ListView<ButtonElement<T>>("buttonCheckSetView", checks) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ButtonElement<T>> item) {
            ButtonElement<T> buttonElement = item.getModelObject();

            Check<T> check = newCheck("buttonCheck", buttonElement.getModel(), checkGroup);
            check.setLabel(buttonElement.getLabel());
            check.setOutputMarkupId(true);

            SimpleFormComponentLabel label = new SimpleFormComponentLabel("buttonCheckLabel", check);

            item.add(check);
            item.add(label);
        }
    };
    checkGroup.add(view);
}