Example usage for org.apache.wicket.markup.html.form FormComponentLabel FormComponentLabel

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

Introduction

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

Prototype

public FormComponentLabel(String id, LabeledWebMarkupContainer component) 

Source Link

Document

Constructor

Usage

From source file:com.github.ilmoeuro.hackmikkeli2016.ui.HomePage.java

License:Open Source License

@Override
protected void onInitialize() {
    super.onInitialize();

    add(new HmListView<Plan>("availablePlans", model, item -> {
        HmLink link = new HmLink("jumpToPlan", () -> {
            model.getObject().setPlan(item.getModelObject());
        });//from  w w w .j  av  a 2  s . c om
        link.add(new HmLabel("title", item));
        item.add(link);
    }));

    add(new HmListView<PlanProposal>("availableProposals", model, item -> {
        HmLink link = new HmLink("jumpToProposal", () -> {
            model.getObject().setProposal(item.getModelObject());
        });
        link.add(new HmLabel("title", item));
        item.add(link);
    }));

    add(votesSaved);
    form.add(new HmButton("saveVotes", () -> {
        model.getObject().saveVotes();
    }));
    form.add(new TextArea("comment", new PropertyModel<String>(model, "comment")));
    form.add(image);
    form.add(new HmListView<UserVoteView.VotesRow>("votes", model, row -> {
        row.add(new HmListView<UserVoteView.VotesCell>("cells", row, cell -> {
            HmCheckBox box = new HmCheckBox("vote", cell);
            cell.add(box);
            cell.add(new FormComponentLabel("voteLabel", box));
        }));
    }));

    add(form);
}

From source file:com.norconex.jefmon.settings.initial.IntroPanel.java

License:Apache License

public IntroPanel(String id) {
    super(id);//from   www. ja va  2 s. c  o  m

    setOutputMarkupId(true);

    DropDownChoice<?> language = new SessionLocaleDropDownChoice("language",
            Arrays.asList(getApp().getSupportedLocales()));
    language.add(new BootstrapSelect());
    add(language);

    add(new FormComponentLabel("languageLabel", language));
}

From source file:cz.zcu.kiv.eegdatabase.wui.components.form.PersonForm.java

License:Apache License

public PersonForm(String id, IModel<Person> model, final EducationLevelFacade educationFacade,
        final PersonFacade personFacade, final FeedbackPanel feedback) {
    super(id, new CompoundPropertyModel<Person>(model));

    final boolean isUserAdmin = EEGDataBaseSession.get().hasRole(UserRole.ROLE_ADMIN.name());

    TextField<String> name = new TextField<String>("givenname");
    name.setLabel(ResourceUtils.getModel("label.name"));
    name.setRequired(true);//w w  w.j  ava 2  s . c o  m
    name.add(new PatternValidator(StringUtils.REGEX_ONLY_LETTERS));
    FormComponentLabel nameLabel = new FormComponentLabel("nameLb", name);
    add(name, nameLabel);

    TextField<String> surname = new TextField<String>("surname");
    surname.setLabel(ResourceUtils.getModel("label.surname"));
    surname.setRequired(true);
    surname.add(new PatternValidator(StringUtils.REGEX_ONLY_LETTERS));
    FormComponentLabel surnameLabel = new FormComponentLabel("surnameLb", surname);
    add(surname, surnameLabel);

    DateTimeFieldPicker date = new DateTimeFieldPicker("dateOfBirth") {

        private static final long serialVersionUID = 1L;

        @Override
        public <C> IConverter<C> getConverter(Class<C> type) {
            return (IConverter<C>) new TimestampConverter();
        }
    };

    date.setLabel(ResourceUtils.getModel("label.dateOfBirth"));
    date.setRequired(true);
    FormComponentLabel dateLabel = new FormComponentLabel("dateLb", date);
    add(date, dateLabel);

    EmailTextField email = new EmailTextField("username");
    email.setLabel(ResourceUtils.getModel("label.email"));
    email.setRequired(true);
    FormComponentLabel emailLabel = new FormComponentLabel("emailLb", email);
    add(email, emailLabel);

    // only for admins

    final PasswordTextField password = new PasswordTextField("password", new Model<String>(""));
    password.setLabel(ResourceUtils.getModel("general.password"));
    password.add(StringValidator.minimumLength(6));
    password.setRequired(false);
    password.setVisibilityAllowed(isUserAdmin);
    password.setVisible(false);
    add(password);

    final PasswordTextField passwordVerify = new PasswordTextField("passwordVerify", new Model<String>(""));
    passwordVerify.setLabel(ResourceUtils.getModel("general.password.verify"));
    passwordVerify.add(StringValidator.minimumLength(6));
    passwordVerify.setRequired(false);
    passwordVerify.setVisibilityAllowed(isUserAdmin);
    passwordVerify.setVisible(false);
    add(passwordVerify);

    final AjaxCheckBox changePasswordBox = new AjaxCheckBox("changePassword",
            new Model<Boolean>(Boolean.FALSE)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {

            Boolean visible = getModelObject();
            password.setVisible(visible);
            password.setRequired(visible);
            passwordVerify.setVisible(visible);
            passwordVerify.setRequired(visible);

            target.add(PersonForm.this);
        }
    };
    changePasswordBox.setVisibilityAllowed(isUserAdmin);
    add(changePasswordBox);
    // end only for admins

    TextField<String> phoneNumber = new TextField<String>("phoneNumber");
    phoneNumber.setLabel(ResourceUtils.getModel("label.phoneNumber"));
    FormComponentLabel phoneNumberLabel = new FormComponentLabel("phoneNumberLb", phoneNumber);
    add(phoneNumber, phoneNumberLabel);

    RadioChoice<Character> gender = new RadioChoice<Character>("gender", Gender.getShortcutList(),
            new ChoiceRenderer<Character>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(Character object) {
                    Gender enumValue = Gender.getGenderByShortcut(object);
                    return getString(
                            Classes.simpleName(enumValue.getDeclaringClass()) + '.' + enumValue.name());
                }

            });
    gender.setSuffix("\n");
    gender.setRequired(true);
    gender.setLabel(ResourceUtils.getModel("label.gender"));
    FormComponentLabel genderLabel = new FormComponentLabel("genderLb", gender);
    add(gender, genderLabel);

    TextArea<String> note = new TextArea<String>("note");
    note.setLabel(ResourceUtils.getModel("label.note"));
    note.add(StringValidator.maximumLength(255));
    FormComponentLabel noteLabel = new FormComponentLabel("noteLb", note);
    add(note, noteLabel);

    DropDownChoice<Character> laterality = new DropDownChoice<Character>("laterality",
            Laterality.getShortcutList(), new ChoiceRenderer<Character>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(Character object) {
                    Laterality enumValue = Laterality.getLateralityByShortcut(object);
                    return getString(
                            Classes.simpleName(enumValue.getDeclaringClass()) + '.' + enumValue.name());
                }

            });

    laterality.setLabel(ResourceUtils.getModel("label.laterality"));
    FormComponentLabel lateralityLabel = new FormComponentLabel("lateralityLb", laterality);
    add(laterality, lateralityLabel);

    DropDownChoice<EducationLevel> educationLevel = new DropDownChoice<EducationLevel>("educationLevel",
            educationFacade.getAllRecords(), new ChoiceRenderer<EducationLevel>("title", "educationLevelId") {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(EducationLevel object) {
                    return object.getEducationLevelId() + " " + super.getDisplayValue(object);
                }

            });

    educationLevel.setLabel(ResourceUtils.getModel("label.educationLevel"));
    FormComponentLabel educationLevelLabel = new FormComponentLabel("educationLevelLb", educationLevel);
    add(educationLevel, educationLevelLabel);

    CheckBox lockCheckBox = new CheckBox("lock");
    add(lockCheckBox);

    CheckBox confirmCheckBox = new CheckBox("confirmed");
    add(confirmCheckBox);

    AjaxButton submit = new AjaxButton("submit", ResourceUtils.getModel("button.save"), this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(feedback);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            Person user = PersonForm.this.getModelObject();
            user.setEmail(user.getUsername().toLowerCase());
            boolean isEdit = user.getPersonId() > 0;

            String planPassword = password.getModelObject();
            String plainPasswordVerify = passwordVerify.getModelObject();
            Boolean isPasswordChanged = changePasswordBox.getModelObject();

            if (validation(user, personFacade, isEdit, isUserAdmin, isPasswordChanged, planPassword,
                    plainPasswordVerify)) {
                if (isEdit) {

                    if (isPasswordChanged)
                        user.setPassword(encodePassword(planPassword));

                    personFacade.update(user);
                } else {
                    user.setAuthority(Util.ROLE_READER);
                    personFacade.create(user);
                }
                setResponsePage(getPage().getClass());
            }

            target.add(feedback);
        }
    };
    add(submit);
}

From source file:cz.zcu.kiv.eegdatabase.wui.components.form.PersonFormPanel.java

License:Apache License

private void init() throws IOException {
    TextField<String> name = new TextField<String>("givenname");
    name.setLabel(ResourceUtils.getModel("general.name"));
    name.setRequired(true);/* w  ww  . ja  v a 2 s .co m*/
    name.add(new PatternValidator(StringUtils.REGEX_ONLY_LETTERS));
    add(name);

    TextField<String> surname = new TextField<String>("surname");
    surname.setLabel(ResourceUtils.getModel("general.surname"));
    surname.setRequired(true);
    surname.add(new PatternValidator(StringUtils.REGEX_ONLY_LETTERS));
    add(surname);

    DateTimeFieldPicker date = new DateTimeFieldPicker("dateOfBirth") {

        private static final long serialVersionUID = 1L;

        @Override
        public <C> IConverter<C> getConverter(Class<C> type) {
            return (IConverter<C>) new TimestampConverter();
        }
    };
    date.setLabel(ResourceUtils.getModel("general.dateofbirth"));
    //date.setRequired(true);
    add(date);

    TextField<String> address = new TextField<String>("address");
    address.setLabel(ResourceUtils.getModel("label.address"));
    add(address);

    TextField<String> city = new TextField<String>("city");
    city.setLabel(ResourceUtils.getModel("label.city"));
    add(city);

    TextField<String> state = new TextField<String>("state");
    state.setLabel(ResourceUtils.getModel("label.state"));
    add(state);

    TextField<String> zipCode = new TextField<String>("zipCode");
    zipCode.setLabel(ResourceUtils.getModel("label.zipCode"));
    add(zipCode);

    TextField<String> url = new TextField<String>("url");
    url.setLabel(ResourceUtils.getModel("label.url"));
    add(url);

    TextField<String> phone = new TextField<String>("phone");
    phone.setLabel(ResourceUtils.getModel("label.phoneNumber"));
    add(phone);

    TextField<String> organization = new TextField<String>("organization");
    organization.setLabel(ResourceUtils.getModel("label.organization"));
    add(organization);

    TextField<String> jobTitle = new TextField<String>("jobTitle");
    jobTitle.setLabel(ResourceUtils.getModel("label.jobTitle"));
    add(jobTitle);

    TextField<String> orgAddress = new TextField<String>("orgAddress");
    orgAddress.setLabel(ResourceUtils.getModel("label.address"));
    add(orgAddress);

    TextField<String> orgCity = new TextField<String>("orgCity");
    orgCity.setLabel(ResourceUtils.getModel("label.city"));
    add(orgCity);

    TextField<String> orgState = new TextField<String>("orgState");
    orgState.setLabel(ResourceUtils.getModel("label.state"));
    add(orgState);

    TextField<String> orgZipCode = new TextField<String>("orgZipCode");
    orgZipCode.setLabel(ResourceUtils.getModel("label.zipCode"));
    add(orgZipCode);

    TextField<String> orgUrl = new TextField<String>("orgUrl");
    orgUrl.setLabel(ResourceUtils.getModel("label.url"));
    add(orgUrl);

    TextField<String> orgPhone = new TextField<String>("orgPhone");
    orgPhone.setLabel(ResourceUtils.getModel("label.phoneNumber"));
    add(orgPhone);

    TextField<String> VAT = new TextField<String>("VAT");
    VAT.setLabel(ResourceUtils.getModel("label.VAT"));
    add(VAT);

    List<String> listOfTitles = new ArrayList<String>();
    listOfTitles.add("Mr.");
    listOfTitles.add("Mrs.");
    listOfTitles.add("Ms.");

    DropDownChoice<String> title = new DropDownChoice<String>("title", listOfTitles,
            new ChoiceRenderer<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(String object) {
                    return object;
                }

            });

    title.setRequired(true);
    title.setLabel(ResourceUtils.getModel("label.title"));
    add(title);

    DropDownChoice<Character> laterality = new DropDownChoice<Character>("laterality",
            Laterality.getShortcutList(), new ChoiceRenderer<Character>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(Character object) {
                    Laterality enumValue = Laterality.getLateralityByShortcut(object);
                    return getString(
                            Classes.simpleName(enumValue.getDeclaringClass()) + '.' + enumValue.name());
                }

            });

    laterality.setLabel(ResourceUtils.getModel("label.laterality"));
    FormComponentLabel lateralityLabel = new FormComponentLabel("lateralityLb", laterality);
    add(laterality, lateralityLabel);

    File file = ResourceUtils.getFile("countries.txt");
    List<String> countries = FileUtils.getFileLines(file);

    DropDownChoice<String> country = new DropDownChoice<String>("country", countries,
            new ChoiceRenderer<String>("country") {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(String object) {
                    return object;
                }

            });

    country.setRequired(true);
    country.setLabel(ResourceUtils.getModel("label.country"));
    add(country);

    DropDownChoice<String> orgCountry = new DropDownChoice<String>("orgCountry", countries,
            new ChoiceRenderer<String>("orgCountry") {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(String object) {
                    return object;
                }

            });

    //orgCountry.setRequired(true);
    orgCountry.setLabel(ResourceUtils.getModel("label.country"));
    add(orgCountry);

    List<String> listOfOrgTypes = new ArrayList<String>();
    listOfOrgTypes.add("Commercial");
    listOfOrgTypes.add("Non-Commercial");

    DropDownChoice<String> organizationType = new DropDownChoice<String>("organizationType", listOfOrgTypes,
            new ChoiceRenderer<String>("organizationType") {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(String object) {
                    return object;
                }

            });

    organizationType.setRequired(true);
    organizationType.setLabel(ResourceUtils.getModel("label.organizationType"));
    add(organizationType);

    DropDownChoice<EducationLevel> educationLevel = new DropDownChoice<EducationLevel>("educationLevel",
            educationLevelFacade.getAllRecords(),
            new ChoiceRenderer<EducationLevel>("title", "educationLevelId") {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(EducationLevel object) {
                    return object.getEducationLevelId() + " " + super.getDisplayValue(object);
                }

            });

    educationLevel.setLabel(ResourceUtils.getModel("general.educationlevel"));
    add(educationLevel);
}

From source file:de.widone.web.authentication.panel.newuser.NewUserPanel.java

License:Apache License

public NewUserPanel(String id) {
    super(id);/*from  w  ww  . ja va2s.c o  m*/
    add(new FeedbackPanel(feedback).setOutputMarkupId(true));

    TextField<String> usernameTextField = (TextField<String>) new TextField("username")
            .add(new StringValidator.LengthBetweenValidator(3, 12));
    PasswordTextField passwordTextField = new PasswordTextField("password");
    PasswordTextField passwordAgainTextField = new PasswordTextField("passwordAgain", Model.of(""));

    add(new Form<User>("newUserForm", new CompoundPropertyModel<User>(new User())).add(usernameTextField)
            .add(passwordTextField).add(passwordAgainTextField)
            .add(new FormComponentLabel("usernameLabel", usernameTextField))
            .add(new FormComponentLabel("passwordLabel", passwordTextField))
            .add(new FormComponentLabel("passwordAgainLabel", passwordAgainTextField))
            .add(new AjaxFallbackLink<Void>("cancel") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    send(getPage(), Broadcast.EXACT, new CancelEvent(target));
                }
            }).add(new AjaxFallbackButton("submit", (Form) get("newUserForm")) {
                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(NewUserPanel.this.get(feedback));
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    send(getPage(), Broadcast.EXACT,
                            new UserCreatedEvent(target, (User) form.getModelObject()));
                }
            }).add(new EqualPasswordInputValidator(passwordTextField, passwordAgainTextField)));
}

From source file:de.widone.web.panel.userdetails.UserDetailsPanel.java

License:Apache License

public UserDetailsPanel(String id, IModel<User> model) {
    super(id, model);
    add(new FeedbackPanel("feedback").setOutputMarkupId(true));

    TextField<String> firstnameTextField = new TextField("firstname");
    TextField<String> lastnameTextField = new TextField("lastname");
    TextField<String> emailTextField = new EmailTextField("email");
    TextField<Date> birthdayTextField = (TextField<Date>) new DateTextField("birthday").add(new DatePicker());
    PasswordTextField passwordTextField = (PasswordTextField) new PasswordTextField("passwordUpdate",
            Model.of("aaaaaa")).setResetPassword(false).setRequired(false);
    PasswordTextField passwordAgainTextField = (PasswordTextField) new PasswordTextField("passwordAgain",
            Model.of("")).setRequired(false);

    add(new Form<User>("userDetailsForm", new CompoundPropertyModel<User>(model)).add(firstnameTextField)
            .add(lastnameTextField).add(emailTextField).add(birthdayTextField).add(passwordTextField)
            .add(passwordAgainTextField).add(new FormComponentLabel("firstnameLabel", firstnameTextField))
            .add(new FormComponentLabel("lastnameLabel", lastnameTextField))
            .add(new FormComponentLabel("emailLabel", emailTextField))
            .add(new FormComponentLabel("birthdayLabel", birthdayTextField))
            .add(new FormComponentLabel("passwordLabel", passwordTextField))
            .add(new FormComponentLabel("passwordAgainLabel", passwordAgainTextField))
            .add(new AjaxFallbackButton("submit", (Form) get("userDetailsForm")) {
                @Override/*from   w w  w. ja  va  2  s . co m*/
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(UserDetailsPanel.this.get("feedback"));
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    send(getPage(), Broadcast.EXACT, new UserUpdatedEvent(target, (User) form.getModelObject(),
                            passwordChanged ? passwordUpdate : null));
                }
            }).add(new AjaxFallbackLink<Void>("cancel") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    send(getPage(), Broadcast.BREADTH, new CancelEvent(target));
                }
            }));
}

From source file:dk.teachus.frontend.components.form.SelectPupilsPanel.java

License:Apache License

public SelectPupilsPanel(String id, IModel<? extends Collection<Pupil>> model) {
    super(id, model);

    selectGroup = new CheckGroup<Pupil>("selectGroup", getModel());
    selectGroup.setRenderBodyOnly(false);
    add(selectGroup);/*  ww  w.  j  a  v a2 s  .  c o  m*/

    // Header
    selectGroup.add(new CheckGroupSelector("selectAll"));
    selectGroup.add(new Label("name", TeachUsSession.get().getString("General.pupil")));

    // Check list model
    IModel<List<Pupil>> pupilsModel = new LoadableDetachableModel<List<Pupil>>() {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<Pupil> load() {
            List<Pupil> pupils = loadPupils();
            return pupils;
        }
    };

    selectGroup.add(new ListView<Pupil>("pupils", pupilsModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Pupil> item) {
            item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() + 1) % 2 == 0 ? "even" : "odd";
                }
            }));

            Check<Pupil> check = new Check<Pupil>("select", item.getModel());
            item.add(check);
            FormComponentLabel label = new FormComponentLabel("label", check);
            item.add(label);
            label.add(new Label("name", new PropertyModel<String>(item.getModel(), "name"))
                    .setRenderBodyOnly(true));
        }
    });
}

From source file:fi.ilmoeuro.membertrack.membership.ui.AccountEditorPanel.java

License:Open Source License

@SuppressWarnings("initialization")
public AccountEditorPanel(String id, IModel<AccountEditor<?>> model) {
    super(id, model);

    this.model = model;

    feedbackPanel = new FeedbackPanel("feedbackPanel");
    newPassword = new MtPasswordField("newPassword", model);
    newPasswordLabel = new FormComponentLabel("newPasswordLabel", newPassword);
    newPasswordAgain = new MtPasswordField("newPasswordAgain", model);
    newPasswordAgainLabel = new FormComponentLabel("newPasswordAgainLabel", newPasswordAgain);
    confirmButton = new MtButton("confirmButton", this::createAccount);
    newPasswordForm = new MtForm<>("newPasswordForm");
}

From source file:fi.ilmoeuro.membertrack.membership.ui.MembershipEditorPanel.java

License:Open Source License

@SuppressWarnings("initialization")
public MembershipEditorPanel(String id, IModel<MembershipEditor<?>> model) {
    super(id, model);

    this.model = model;
    final IModel<Membership> membershipModel = new PropertyModel<>(model, "membership");

    feedbackPanel = new FeedbackPanel("feedbackPanel");

    deleteForm = new MtForm<>("deleteForm", membershipModel);
    personNameLabel = new MtLabel("person.fullName", membershipModel);
    confirmButton = new MtButton("confirmButton", this::save);
    cancelButton = new MtButton("cancelButton", this::unDelete);

    editorForm = new MtForm<>("editorForm", membershipModel);
    personFirstNameField = new MtTextField<>("person.firstName", membershipModel);
    personFirstNameLabel = new FormComponentLabel("person.firstName.label", personFirstNameField);
    personLastNameField = new MtTextField<>("person.lastName", membershipModel);
    personLastNameLabel = new FormComponentLabel("person.lastName.label", personLastNameField);
    personEmailField = new MtTextField<>("person.email", membershipModel);
    personEmailLabel = new FormComponentLabel("person.email.label", personEmailField);

    numbersSection = new MtListView<>("phoneNumbers", membershipModel, (ListItem<PhoneNumber> item) -> {
        MtTextField<String> numberField = new MtTextField<>("phoneNumber", item);
        MtButton deleteNumber = new MtButton("deleteNumber", () -> deletePhoneNumber(item));
        if (item.getModelObject().isDeleted()) {
            item.setVisible(false);/*from ww w  . j  ava  2 s . c o m*/
        }
        item.add(numberField);
        item.add(deleteNumber);
    });
    addNumber = new MtButton("addNumber", this::newPhoneNumber);

    secondaryEmailsSection = new MtListView<>("secondaryEmails", membershipModel,
            (ListItem<SecondaryEmail> item) -> {
                MtTextField<String> emailField = new MtTextField<>("email", item);
                MtButton deleteSecondaryEmail = new MtButton("deleteSecondaryEmail",
                        () -> deleteSecondaryEmail(item));
                if (item.getModelObject().isDeleted()) {
                    item.setVisible(false);
                }
                item.add(emailField);
                item.add(deleteSecondaryEmail);
            });
    addSecondaryEmail = new MtButton("addSecondaryEmail", this::newSecondaryEmail);

    subscriptionsSection = new MtListView<>("subscriptions", membershipModel,
            (ListItem<Subscription> subItem) -> {
                MtLabel legend = new MtLabel("service.title", subItem);
                MtListView<SubscriptionPeriod> periodsSection = new MtListView<>("periods", subItem,
                        (ListItem<SubscriptionPeriod> prdItem) -> {
                            if (prdItem.getModelObject().isDeleted()) {
                                prdItem.setVisible(false);
                            }
                            MtTextField<LocalDate> startDateField = new MtTextField<>("startDate", prdItem);
                            MtTextField<Integer> lengthField = new MtTextField<>("length", prdItem);
                            MtTextField<Double> paymentField = new MtTextField<>("paymentFormatted", prdItem);
                            DropDownChoice<PeriodTimeUnit> lengthUnitField = new DropDownChoice<PeriodTimeUnit>(
                                    "lengthUnit",
                                    new PropertyModel<PeriodTimeUnit>(prdItem.getModel(), "lengthUnit"),
                                    new PropertyModel<List<PeriodTimeUnit>>(prdItem.getModel(),
                                            "possibleLengthUnits"));
                            CheckBox approvedField = new CheckBox("approved",
                                    new PropertyModel<>(prdItem.getModel(), "approved"));

                            MtButton deletePeriod = new MtButton("deletePeriod",
                                    () -> deleteSubscriptionPeriod(prdItem));

                            prdItem.add(startDateField);
                            prdItem.add(lengthField);
                            prdItem.add(paymentField);
                            prdItem.add(lengthUnitField);
                            prdItem.add(approvedField);
                            prdItem.add(deletePeriod);
                        });
                MtButton addPeriod = new MtButton("addPeriod", () -> newSubscriptionPeriod(subItem));
                subItem.add(legend);
                subItem.add(periodsSection);
                subItem.add(addPeriod);
            });

    saveButton = new MtButton("saveButton", this::save);
    deleteButton = new MtButton("deleteButton", this::delete);
}

From source file:name.martingeisse.wicket.component.stdform.StandardFormPanel.java

License:Open Source License

/**
 * Adds a form control wrapper fragment for the specified form control.
 * /*from   w  w w  .  ja v  a 2  s  .  c  o  m*/
 * @param label the label for the form control
 * @param formControl the form control to wrap
 * @param labelTarget the component to refer to in the "for" attribute of the label.
 * This parameter may be null; in this case, the "for" attribute will be omitted.
 * @param errorSource the source for error messages. This parameter may be null;
 * in this case, no error messages will be shown.
 * @return the wrapper fragment
 */
public final Fragment addFormControl(final String label, final Component formControl,
        final LabeledWebMarkupContainer labelTarget, final Component errorSource) {
    final Fragment wrapperFragment = new Fragment(newRawFormElementId(), "formControlWrapperFragment", this);
    wrapperFragment.add(new BootstrapComponentFeedbackPanel("error", errorSource));
    wrapperFragment.add(new FormComponentLabel("label", labelTarget).add(new Label("text", label)));
    wrapperFragment.add(new Label("helpText"));
    wrapperFragment.add(new RepeatingView("toolLinks"));
    wrapperFragment.add(formControl);
    addRawFormElement(wrapperFragment);
    return wrapperFragment;
}