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

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

Introduction

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

Prototype

public RadioGroup(String id) 

Source Link

Usage

From source file:com.customeric.panels.AccountFormPanel.java

public AccountFormPanel(String id, IModel<Accounts> model) {
    super(id, model);
    if (model == null) {
        model = new Model<Accounts>(new Accounts());
    }//from w w w .  j a  va2  s  .  co  m
    final Form<Accounts> accountForm = new Form<Accounts>("accountForm",
            new CompoundPropertyModel<Accounts>(model)) {
        @Override
        protected void onSubmit() {
            super.onSubmit();
            final Accounts account = getModelObject();
            try {
                if (account.getId() == null) {
                    DocamineServiceFactory.getAccountsJpaController().create(account);
                } else {
                    DocamineServiceFactory.getAccountsJpaController().edit(account);
                }

            } catch (Exception ex) {
                log.error("Not able to save account in Account Form");
            }

        }

    };
    add(accountForm);
    final TextField companyName = new TextField("companyName");
    final EmailTextField companyEmailAddress = new EmailTextField("companyEmailAddress");
    final TextField phoneNumber = new TextField("phoneNumber");
    final TextField street1 = new TextField("street1");
    final TextField street2 = new TextField("street2");
    final TextField zip = new TextField("zip");
    final TextField city = new TextField("city");
    final TextField state = new TextField("state");
    final TextField country = new TextField("country");
    final TextField twitterHandle = new TextField("twitterHandle");
    final TextField facebookHandle = new TextField("facebookHandle");
    final TextField linkdedInHandle = new TextField("linkdedInHandle");
    final TextField skypeHandle = new TextField("skypeHandle");
    final TextField blogUrl = new TextField("blogUrl");
    final TextArea comments = new TextArea("comments");

    final RadioGroup radioGroup = new RadioGroup("customerTypeChoice");
    radioGroup.add(new Radio("premium", new Model<String>("premium")));
    radioGroup.add(new Radio("valued", new Model<String>("valued")));
    radioGroup.add(new Radio("normal", new Model<String>("normal")));

    accountForm.add(companyName).add(companyEmailAddress).add(phoneNumber).add(street1).add(street2).add(zip)
            .add(city).add(state).add(country).add(twitterHandle).add(facebookHandle).add(linkdedInHandle)
            .add(skypeHandle).add(blogUrl).add(comments).add(radioGroup);
}

From source file:com.customeric.panels.LeadFormPanel.java

public LeadFormPanel(String id, IModel<Leads> model) {
    super(id, model);
    if (model == null) {
        model = new Model<Leads>(new Leads());
    }/*ww w  . ja  v a2s . c  o m*/
    final Form<Leads> leadForm = new Form<Leads>("leadForm", new CompoundPropertyModel<Leads>(model)) {
        @Override
        protected void onSubmit() {
            super.onSubmit();
            final Leads lead = getModelObject();
            try {
                DocamineServiceFactory.getLeadsJpaController().edit(lead);
            } catch (Exception ex) {
                log.error("Not able to save lead in lead Form");
            }

        }

    };
    add(leadForm);
    final DropDownChoice title = new DropDownChoice("title", Arrays.asList("Mr", "Mrs", "Miss", "Dr"));
    final TextField firstName = new TextField("firstName");
    final TextField lastName = new TextField("lastName");
    final TextField companyName = new TextField("companyName");
    final EmailTextField companyEmailAddress = new EmailTextField("companyEmailAddress");
    final TextField phoneNumber = new TextField("phoneNumber");
    final TextField street1 = new TextField("street1");
    final TextField street2 = new TextField("street2");
    final TextField zip = new TextField("zip");
    final TextField city = new TextField("city");
    final TextField stateName = new TextField("stateName");
    final TextField country = new TextField("country");
    final TextField twitterHandle = new TextField("twitterHandle");
    final TextField facebookHandle = new TextField("facebookHandle");
    final TextField linkdedInHandle = new TextField("linkdedInHandle");
    final TextField skypeHandle = new TextField("skypeHandle");
    final TextField blogUrl = new TextField("blogUrl");
    final TextArea comments = new TextArea("comments");

    final RadioGroup radioGroup = new RadioGroup("leadTypeChoice");
    radioGroup.add(new Radio("hot", new Model<String>("hot")));
    radioGroup.add(new Radio("cold", new Model<String>("cold")));
    radioGroup.add(new Radio("warm", new Model<String>("warm")));

    leadForm.add(title).add(firstName).add(lastName).add(companyName).add(companyEmailAddress).add(phoneNumber)
            .add(street1).add(street2).add(zip).add(city).add(stateName).add(country).add(twitterHandle)
            .add(facebookHandle).add(linkdedInHandle).add(skypeHandle).add(blogUrl).add(comments)
            .add(radioGroup);
}

From source file:com.doculibre.constellio.wicket.panels.search.SearchFormPanel.java

License:Open Source License

@SuppressWarnings({ "rawtypes", "unchecked" })
public SearchFormPanel(String id, final IModel simpleSearchModel) {
    super(id);// w w w  . ja  v  a2  s.  co  m

    searchForm = new WebMarkupContainer("searchForm", new CompoundPropertyModel(simpleSearchModel));

    simpleSearchFormDiv = new WebMarkupContainer("simpleSearchFormDiv") {
        @Override
        public boolean isVisible() {
            SimpleSearch search = (SimpleSearch) simpleSearchModel.getObject();
            return search.getAdvancedSearchRule() == null;
        }
    };
    advancedSearchFormDiv = new WebMarkupContainer("advancedSearchFormDiv") {
        @Override
        public boolean isVisible() {
            SimpleSearch search = (SimpleSearch) simpleSearchModel.getObject();
            return search.getAdvancedSearchRule() != null;
        }
    };

    advancedSearchPanel = new AdvancedSearchPanel("advanceForm", simpleSearchModel);

    searchForm.add(new AttributeModifier("action", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
            return urlFor(pageFactoryPlugin.getSearchResultsPage(), new PageParameters());
        }
    }));

    hiddenFields = new ListView("hiddenFields", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            List<SimpleParam> hiddenParams = new ArrayList<SimpleParam>();
            HiddenSearchFormParamsPlugin hiddenSearchFormParamsPlugin = PluginFactory
                    .getPlugin(HiddenSearchFormParamsPlugin.class);

            if (hiddenSearchFormParamsPlugin != null) {
                WebRequestCycle webRequestCycle = (WebRequestCycle) RequestCycle.get();
                HttpServletRequest request = webRequestCycle.getWebRequest().getHttpServletRequest();
                SimpleParams hiddenSimpleParams = hiddenSearchFormParamsPlugin.getHiddenParams(request);
                for (String paramName : hiddenSimpleParams.keySet()) {
                    for (String paramValue : hiddenSimpleParams.getList(paramName)) {
                        hiddenParams.add(new SimpleParam(paramName, paramValue));
                    }
                }
            }

            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            SimpleSearch clone = simpleSearch.clone();

            SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
                    .getSearchInterfaceConfigServices();
            SearchInterfaceConfig config = searchInterfaceConfigServices.get();
            if (!config.isKeepFacetsNewSearch()) {
                // Will be true if we just clicked on a delete link
                // on the CurrentSearchPanel
                if (!clone.isRefinedSearch()) {
                    clone.getSearchedFacets().clear();
                    clone.setCloudKeyword(null);
                }
                // We must click on a delete link on
                // CurrentSearchPanel so that it is considered
                // again as refined
                clone.setRefinedSearch(false);
            }

            clone.initFacetPages();

            List<String> ignoredParamNames = Arrays.asList("query", "searchType", "page", "singleSearchLocale");
            SimpleParams searchParams = clone.toSimpleParams();
            for (String paramName : searchParams.keySet()) {
                if (!ignoredParamNames.contains(paramName) && !paramName.contains(SearchRule.ROOT_PREFIX)) {
                    List<String> paramValues = searchParams.getList(paramName);
                    for (String paramValue : paramValues) {
                        SimpleParam hiddenParam = new SimpleParam(paramName, paramValue);
                        hiddenParams.add(hiddenParam);
                    }
                }
            }
            return hiddenParams;
        }
    }) {
        @Override
        protected void populateItem(ListItem item) {
            SimpleParam hiddenParam = (SimpleParam) item.getModelObject();
            if (hiddenParam.value != null) {
                item.add(new SimpleAttributeModifier("name", hiddenParam.name));
                item.add(new SimpleAttributeModifier("value", hiddenParam.value));
            } else {
                item.setVisible(false);
            }
        }
    };

    SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
            .getSearchInterfaceConfigServices();
    SearchInterfaceConfig config = searchInterfaceConfigServices.get();

    if (config.isSimpleSearchAutocompletion()
            && ((SimpleSearch) simpleSearchModel.getObject()).getAdvancedSearchRule() == null) {
        AutoCompleteSettings settings = new AutoCompleteSettings();
        settings.setCssClassName("simpleSearchAutoCompleteChoices");
        IModel model = new Model(((SimpleSearch) simpleSearchModel.getObject()).getQuery());

        WordsAndValueAutoCompleteRenderer render = new WordsAndValueAutoCompleteRenderer() {
            @Override
            protected String getTextValue(String word, Object value) {
                return word;
            }
        };

        queryField = new TextAndValueAutoCompleteTextField("query", model, String.class, settings, render) {
            @Override
            public String getInputName() {
                return super.getId();
            }

            @Override
            protected Iterator getChoicesForWord(String word) {
                SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
                String collectionName = simpleSearch.getCollectionName();
                AutocompleteServices autocompleteServices = ConstellioSpringUtils.getAutocompleteServices();
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                RecordCollection collection = collectionServices.get(collectionName);
                List<String> suggestions = autocompleteServices.suggestSimpleSearch(word, collection,
                        getLocale());
                return suggestions.iterator();
            }

            @Override
            protected boolean supportMultipleWords() {
                return false;
            }
        };
    } else {
        queryField = new TextField("query") {
            @Override
            public String getInputName() {
                return super.getId();
            }
        };
    }

    searchTypeField = new RadioGroup("searchType") {
        @Override
        public String getInputName() {
            return super.getId();
        }
    };

    IModel languages = new LoadableDetachableModel() {
        protected Object load() {
            Set<String> localeCodes = new HashSet<String>();
            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            RecordCollectionServices recordCollectionServices = ConstellioSpringUtils
                    .getRecordCollectionServices();
            RecordCollection collection = recordCollectionServices.get(simpleSearch.getCollectionName());
            List<Locale> searchableLocales = ConstellioSpringUtils.getSearchableLocales();
            if (!collection.isOpenSearch()) {
                localeCodes.add("");
                if (!searchableLocales.isEmpty()) {
                    for (Locale searchableLocale : searchableLocales) {
                        localeCodes.add(searchableLocale.getLanguage());
                    }
                } else {
                    IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
                    IndexField languageField = indexFieldServices.get(IndexField.LANGUAGE_FIELD, collection);
                    for (String localeCode : indexFieldServices.suggestValues(languageField)) {
                        localeCodes.add(localeCode);
                    }
                }
            } else {
                localeCodes.add("");
                if (!searchableLocales.isEmpty()) {
                    for (Locale searchableLocale : searchableLocales) {
                        localeCodes.add(searchableLocale.getLanguage());
                    }
                } else {
                    for (Locale availableLocale : Locale.getAvailableLocales()) {
                        localeCodes.add(availableLocale.getLanguage());
                    }
                }
            }
            List<Locale> locales = new ArrayList<Locale>();
            for (String localeCode : localeCodes) {
                locales.add(new Locale(localeCode));
            }
            Collections.sort(locales, new Comparator<Locale>() {
                @Override
                public int compare(Locale locale1, Locale locale2) {
                    Locale locale1Display;
                    Locale locale2Display;
                    SearchInterfaceConfig config = ConstellioSpringUtils.getSearchInterfaceConfigServices()
                            .get();
                    if (config.isTranslateLanguageNames()) {
                        locale1Display = locale2Display = getLocale();
                    } else {
                        locale1Display = locale1;
                        locale2Display = locale2;
                    }

                    List<Locale> searchableLocales = ConstellioSpringUtils.getSearchableLocales();
                    if (searchableLocales.isEmpty()) {
                        searchableLocales = ConstellioSpringUtils.getSupportedLocales();
                    }

                    Integer indexOfLocale1;
                    Integer indexOfLocale2;
                    if (locale1.getLanguage().equals(getLocale().getLanguage())) {
                        indexOfLocale1 = Integer.MIN_VALUE;
                    } else {
                        indexOfLocale1 = searchableLocales.indexOf(locale1);
                    }
                    if (locale2.getLanguage().equals(getLocale().getLanguage())) {
                        indexOfLocale2 = Integer.MIN_VALUE;
                    } else {
                        indexOfLocale2 = searchableLocales.indexOf(locale2);
                    }

                    if (indexOfLocale1 == -1) {
                        indexOfLocale1 = Integer.MAX_VALUE;
                    }
                    if (indexOfLocale2 == -1) {
                        indexOfLocale2 = Integer.MAX_VALUE;
                    }
                    if (!indexOfLocale1.equals(Integer.MAX_VALUE)
                            || !indexOfLocale2.equals(Integer.MAX_VALUE)) {
                        return indexOfLocale1.compareTo(indexOfLocale2);
                    } else if (StringUtils.isBlank(locale1.getLanguage())) {
                        return Integer.MIN_VALUE;
                    } else {
                        return locale1.getDisplayLanguage(locale1Display)
                                .compareTo(locale2.getDisplayLanguage(locale2Display));
                    }
                }
            });
            return locales;
        }
    };

    IChoiceRenderer languageRenderer = new ChoiceRenderer() {
        @Override
        public Object getDisplayValue(Object object) {
            Locale locale = (Locale) object;
            String text;
            if (locale.getLanguage().isEmpty()) {
                text = (String) new StringResourceModel("all", SearchFormPanel.this, null).getObject();
            } else {
                Locale localeDisplay;
                SearchInterfaceConfig config = ConstellioSpringUtils.getSearchInterfaceConfigServices().get();
                if (config.isTranslateLanguageNames()) {
                    localeDisplay = getLocale();
                } else {
                    localeDisplay = locale;
                }
                text = StringUtils.capitalize(locale.getDisplayLanguage(localeDisplay));
            }
            return text;
        }

        @Override
        public String getIdValue(Object object, int index) {
            return ((Locale) object).getLanguage();
        }
    };

    IModel languageModel = new Model() {
        @Override
        public Object getObject() {
            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            Locale singleSearchLocale = simpleSearch.getSingleSearchLocale();
            if (singleSearchLocale == null) {
                SearchedFacet facet = simpleSearch.getSearchedFacet(IndexField.LANGUAGE_FIELD);
                List<String> values = facet == null ? new ArrayList<String>() : facet.getIncludedValues();
                singleSearchLocale = values.isEmpty() ? null : new Locale(values.get(0));
            }
            if (singleSearchLocale == null) {
                singleSearchLocale = getLocale();
            }
            return singleSearchLocale;
        }

        @Override
        public void setObject(Object object) {
            Locale singleSearchLocale = (Locale) object;
            SimpleSearch simpleSearch = (SimpleSearch) simpleSearchModel.getObject();
            simpleSearch.setSingleSearchLocale(singleSearchLocale);
        }
    };

    languageDropDown = new DropDownChoice("singleSearchLocale", languageModel, languages, languageRenderer) {
        @Override
        public String getInputName() {
            return "singleSearchLocale";
        }

        @Override
        public boolean isVisible() {
            SearchInterfaceConfigServices searchInterfaceConfigServices = ConstellioSpringUtils
                    .getSearchInterfaceConfigServices();
            SearchInterfaceConfig config = searchInterfaceConfigServices.get();
            return config.isLanguageInSearchForm();
        }

        @Override
        protected CharSequence getDefaultChoice(Object selected) {
            return "";
        };
    };

    searchButton = new Button("searchButton") {
        @Override
        public String getMarkupId() {
            return super.getId();
        }

        @Override
        public String getInputName() {
            return super.getId();
        }
    };

    String submitImgUrl = "" + urlFor(new ResourceReference(BaseConstellioPage.class, "images/ico_loupe.png"));

    add(searchForm);
    searchForm.add(simpleSearchFormDiv);
    searchForm.add(advancedSearchFormDiv);
    searchForm.add(hiddenFields);

    queryField.add(new SetFocusBehavior(queryField));

    addChoice(SimpleSearch.ALL_WORDS);
    addChoice(SimpleSearch.AT_LEAST_ONE_WORD);
    addChoice(SimpleSearch.EXACT_EXPRESSION);
    simpleSearchFormDiv.add(queryField);
    simpleSearchFormDiv.add(searchTypeField);
    simpleSearchFormDiv.add(languageDropDown);
    simpleSearchFormDiv.add(searchButton);
    advancedSearchFormDiv.add(advancedSearchPanel);
    searchButton.add(new SimpleAttributeModifier("src", submitImgUrl));
}

From source file:com.fdorigo.rmfly.wicket.RecordPage.java

private void init() {
    add(new FeedbackPanel("feedback"));

    final DateTextField dateTextField = new DateTextField("arrivalDate");
    dateTextField.setRequired(true);/*  ww w.  j av a2  s .c o m*/

    DatePicker datePicker = new DatePicker() {
        @Override
        protected String getAdditionalJavaScript() {
            return "${calendar}.cfg.setProperty(\"navigator\",true,false); ${calendar}.render();";
        }
    };
    datePicker.setShowOnFieldClick(true);
    datePicker.setAutoHide(true);
    dateTextField.add(datePicker);

    final TextField<String> nNumberField = new TextField<>("nnumber");
    nNumberField.setRequired(true);
    if (validNnumber) {
        nNumberField.add(AttributeModifier.append("readonly", "true"));
    } else {
        nNumberField.add(AttributeModifier.append("placeholder", "Not Found"));
    }

    DropDownChoice<AirplaneType> listCategories = new DropDownChoice<>("category",
            new PropertyModel<>(this, "selected"), Arrays.asList(AirplaneType.values()));
    listCategories.setRequired(true);

    final TextField<String> firstNameField = new TextField<>("firstName");
    final TextField<String> lastNameField = new TextField<>("lastName");
    final TextField<String> primaryPhoneField = new TextField<>("primaryPhone");
    primaryPhoneField.setRequired(true);
    final TextField<String> secondaryPhoneField = new TextField<>("secondaryPhone");
    final TextField<String> addressOneField = new TextField<>("addressOne");
    final TextField<String> addressStateField = new TextField<>("addressState");
    final TextField<String> addressCityField = new TextField<>("addressCity");
    final TextField<String> addressZipField = new TextField<>("addressZip");
    final TextField<String> emailAddressField = new TextField<>("emailAddress");
    emailAddressField.add(EmailAddressValidator.getInstance());
    emailAddressField.setRequired(true);
    final TextField<String> airplaneMakeField = new TextField<>("airplaneMake");
    final TextField<String> airplaneModelField = new TextField<>("airplaneModel");
    final NumberTextField<Integer> manufactureYearField = new NumberTextField<>("manufactureYear");
    manufactureYearField.setType(Integer.class);
    int year = Calendar.getInstance().get(Calendar.YEAR);
    manufactureYearField.setMinimum(1903).setMaximum(year);

    RadioGroup<String> group = new RadioGroup<>("needJudging");
    group.setRequired(true);
    add(group);
    ListView<Boolean> radios = new ListView<Boolean>("radios", TRUE_FALSE) {
        @Override
        protected void populateItem(ListItem<Boolean> item) {
            Radio<Boolean> radio = new Radio<>("radio", item.getModel());
            radio.setLabel(new Model(item.getModelObject()));
            item.add(radio);
            item.add(new SimpleFormComponentLabel("boolval", radio));
        }
    }.setReuseItems(true);
    group.add(radios);

    Model<Record> recordModel = new Model<>(record);
    Form<Record> recordForm = new Form<>("recordForm", new CompoundPropertyModel<>(recordModel));

    final Button saveRecordButton = new Button("save") {
        @Override
        public void onSubmit() {
            record.setCategory(selected.toString());
            if (manufactureYearField.getInput() != null) {
                record.setManufactureYear(manufactureYearField.getInput());
            }
            recordFacade.edit(record);
            setResponsePage(HomePage.class);
        }
    };
    if (formControlsEnabled != true) {
        saveRecordButton.setVisible(false);
    }
    recordForm.add(saveRecordButton);

    final Button deleteRecordButton = new Button("delete") {
        @Override
        public void onSubmit() {
            recordFacade.remove(record);
            setResponsePage(HomePage.class);
        }
    };

    deleteRecordButton.setDefaultFormProcessing(false);
    if (formControlsEnabled != true) {
        deleteRecordButton.setVisible(false);
    }
    recordForm.add(deleteRecordButton);

    add(recordForm);

    recordForm.add(nNumberField);
    recordForm.add(firstNameField);
    recordForm.add(lastNameField);
    recordForm.add(secondaryPhoneField);
    recordForm.add(addressOneField);
    recordForm.add(addressStateField);
    recordForm.add(addressCityField);
    recordForm.add(addressZipField);
    recordForm.add(emailAddressField);
    recordForm.add(airplaneMakeField);
    recordForm.add(airplaneModelField);
    recordForm.add(manufactureYearField);

    /* Mandatory Fields */
    recordForm.add(dateTextField);
    recordForm.add(primaryPhoneField);
    recordForm.add(group);
    recordForm.add(listCategories);
    //        recordForm.add(new FormComponentFeedbackBorder("arrivalDateBorder").add(dateTextField));
    //        recordForm.add(new FormComponentFeedbackBorder("primaryPhoneBorder").add(primaryPhoneField));
    //        recordForm.add(new FormComponentFeedbackBorder("needJudgingBorder").add(group));
    //        recordForm.add(new FormComponentFeedbackBorder("categoryBorder").add(listCategories));
}

From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationCreatePanel.java

License:Apache License

private void createAppForm() {

    appForm = new Form<>("appForm", new CompoundPropertyModel<>(new FirstApplicationReleaseInfos()));

    TextField<String> appLabel = new TextField<>("appLabel");
    appLabel.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.label.label"));

    appLabel.add(new AbstractValidator<String>() {
        @Override//from w  ww. j av a 2s .c o  m
        protected void onValidate(IValidatable<String> iValidatable) {
            if (!parentPage.isApplicationLabelUnique(iValidatable.getValue())) {
                error(iValidatable);
            }
        }

        @Override
        protected String resourceKey() {
            return "portal.application.label.non.unique";
        }

        @Override
        protected Map<String, Object> variablesMap(IValidatable<String> stringIValidatable) {
            Map<String, Object> map = super.variablesMap(stringIValidatable);
            map.put("label", stringIValidatable.getValue());
            return map;
        }
    });
    appLabel.add(new PropertyValidator<>());
    appForm.add(appLabel);

    TextField<String> appCode = new TextField<>("appCode");
    appCode.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.code.label"));
    appCode.add(new PropertyValidator<>());
    appForm.add(appCode);

    TextArea<String> appDescription = new TextArea<>("appDescription");
    appDescription.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.description.label"));
    appDescription.add(new PropertyValidator<>());
    appForm.add(appDescription);

    RadioGroup<Boolean> appVisibility = new RadioGroup<>("appPublic");
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-public", new Model<>(Boolean.TRUE)));
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-private", new Model<>(Boolean.FALSE)));
    appVisibility.add(new PropertyValidator<>());
    appForm.add(appVisibility);
    appForm.add(
            new CacheActivatedImage("imageHelp.visibilityField", new ResourceModel("image.help").getObject()));

    TextField<String> members = new TextField<>("members");
    members.add(new PropertyValidator<>());
    appForm.add(members);
    appForm.add(new CacheActivatedImage("imageHelp.membersField", new ResourceModel("image.help").getObject()));

    releaseFiedsetPanel = new ReleaseFieldsetPanel("releaseFieldsetPanel", parentPage,
            manageApplicationRelease);
    appForm.add(releaseFiedsetPanel);

    createFormButtons(appForm);

    // set default visibility to private
    appForm.getModelObject().setAppPublic(Boolean.FALSE);

    add(appForm);
}

From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationInformationPanel.java

License:Apache License

private void createEditShowInformationComponent(Application app) {

    appForm = new Form<>("appForm");
    appForm.setDefaultModel(new CompoundPropertyModel<Application>(app));

    label = new TextField<>("label");
    label.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.label.label"));
    label.add(new PropertyValidator<>());
    appForm.add(label);//  w  ww  .ja  v  a2 s. co  m

    code = new TextField<>("code");
    code.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.code.label"));
    code.add(new PropertyValidator<>());
    appForm.add(code);

    appVisibility = new RadioGroup<>("isPublic");
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-public", new Model<>(Boolean.TRUE)));
    appVisibility.add(new Radio<Boolean>("appVisibilityRadioGroup-private", new Model<>(Boolean.FALSE)));
    appVisibility.add(new PropertyValidator<>());

    appVisibility.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.visibility.label"));

    users = new TextField<>("members", new PropertyModel<String>(this, "members"));
    users.add(new PropertyValidator<>());
    appForm.add(users);
    appForm.add(new CacheActivatedImage("membersHelp", new ResourceModel("image.help").getObject()));

    appForm.add(appVisibility);

    description = new TextArea<>("description");
    description.setLabel(WicketUtils.getStringResourceModel(this, "portal.application.description.label"));
    description.add(new PropertyValidator<>());
    appForm.add(description);

    add(appForm);
    createButtons();
    manageButtonsVisibility();
    updateEditableInput();
}

From source file:gr.interamerican.wicket.utils.WicketPage.java

License:Open Source License

/**
 * //from  w ww. j a va 2  s. co  m
 */
public WicketPage() {

    //FeedBackPanel
    add(WicketUtils.createFeedbackPanel());

    //Test CreateLink
    Link<String> link = LinkUtils.createLink("link", this.getClass()); //$NON-NLS-1$
    add(link);
    Link<String> link1 = LinkUtils.createLink(this.getClass());
    add(link1);
    Link<String> link2 = LinkUtils
            .createLink(new Pair<String, Class<? extends Page>>("link2", this.getClass())); //$NON-NLS-1$
    add(link2);

    //Test CheckBoxPanel
    CheckBoxPanelImpl<Boolean> testCheckBoxPanel = new CheckBoxPanelImpl<Boolean>("checkBoxPanel", //$NON-NLS-1$
            new Model<Boolean>(), true);
    add(testCheckBoxPanel);

    //Test DataTableLinkPanel
    DataTableLinkPanelImpl testDataTableLinkPanel = new DataTableLinkPanelImpl("dateTableLinkPanel", //$NON-NLS-1$
            new Model(), ImageType.COPY);
    add(testDataTableLinkPanel);
    DataTableLinkPanelImpl testDataTableLinkPanel1 = new DataTableLinkPanelImpl("dateTableLinkPanel1", //$NON-NLS-1$
            new Model(), "This is a test"); //$NON-NLS-1$
    add(testDataTableLinkPanel1);

    //Test StatefulAjaxTabbedPanel
    StatefulAjaxTabbedPanel tabs = new StatefulAjaxTabbedPanel("tabs", getITabs(), new Form("form"), null); //$NON-NLS-1$ //$NON-NLS-2$
    add(tabs);

    //Test DataTableRadioButtonPanel      
    RadioGroup radioGroup = new RadioGroup("radioGroup"); //$NON-NLS-1$
    DataTableRadioButtonPanel<Serializable> dataTableRadioButtionPanel = new DataTableRadioButtonPanel<Serializable>(
            "dataTableRadioButtonPanel", new Model()); //$NON-NLS-1$
    radioGroup.add(dataTableRadioButtionPanel);
    add(radioGroup);

    //Test WicketUtils methods
    Form form2 = new Form("form2"); //$NON-NLS-1$
    TextField<String> textField = new TextField<String>("field"); //$NON-NLS-1$
    textField.setOutputMarkupId(true);
    form2.add(textField);
    WicketUtils.setVisibility(form2, new String[] { "field" }, true); //$NON-NLS-1$
    WicketUtils.renderFields(new AjaxRequestTarget(this), form2, new String[] { "field" }); //$NON-NLS-1$
    add(form2);

}

From source file:org.apache.openmeetings.web.common.InvitationForm.java

License:Apache License

public InvitationForm(String id) {
    super(id, new CompoundPropertyModel<Invitation>(new Invitation()));
    setOutputMarkupId(true);//from ww w .  j  a  v  a2  s.  co m

    add(subject, message);
    recipients.setLabel(Model.of(Application.getString(216))).setRequired(true)
            .add(new AjaxFormComponentUpdatingBehavior("change") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    url.setModelObject(null);
                    updateButtons(target);
                }
            }).setOutputMarkupId(true);
    add(new AjaxCheckBox("passwordProtected") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            InvitationForm.this.getModelObject().setPasswordProtected(getConvertedInput());
            passwd.setEnabled(getConvertedInput());
            target.add(passwd);
        }
    });
    RadioGroup<Valid> valid = new RadioGroup<Valid>("valid");
    valid.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            boolean dateEnabled = InvitationForm.this.getModelObject().getValid() == Valid.Period;
            target.add(from.setEnabled(dateEnabled), to.setEnabled(dateEnabled),
                    timeZoneId.setEnabled(dateEnabled));
        }
    });
    add(valid.add(new Radio<Valid>("one", Model.of(Valid.OneTime)),
            new Radio<Valid>("period", Model.of(Valid.Period)),
            new Radio<Valid>("endless", Model.of(Valid.Endless))));
    add(passwd = new PasswordTextField("password"));
    Invitation i = getModelObject();
    passwd.setLabel(Model.of(Application.getString(525))).setOutputMarkupId(true)
            .setEnabled(i.isPasswordProtected());
    add(from, to, timeZoneId);
    from.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
    to.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
    timeZoneId.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true)
            .add(new AjaxFormComponentUpdatingBehavior("change") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    //no-op added to preserve selection
                }
            });
    add(url.setOutputMarkupId(true));
    add(lang, feedback);
}

From source file:org.artifactory.addon.wicket.WicketAddonsImpl.java

License:Open Source License

@Override
public void createAndAddRepoConfigDockerSection(Form form, RepoDescriptor repoDescriptor, boolean isCreate) {
    WebMarkupContainer dockerSection = new WebMarkupContainer("dockerSupportSection");
    dockerSection.add(new TitledBorderBehavior("fieldset-border", "Docker"));
    dockerSection.add(new DisabledAddonBehavior(AddonType.DOCKER));
    dockerSection//from   w  ww .  j av  a2s  .  c o m
            .add(new StyledCheckbox("enableDockerSupport").setTitle("Enable Docker Support").setEnabled(false));
    dockerSection.add(new SchemaHelpBubble("enableDockerSupport.help"));
    Label label = new Label("dockerRepoUrlLabel", "");
    label.setVisible(false);
    dockerSection.add(label);

    if (repoDescriptor instanceof LocalRepoDescriptor) {
        final RadioGroup dockerApiVersion = new RadioGroup("dockerApiVersion");
        dockerApiVersion.add(new Radio<>("v1", Model.of(DockerApiVersion.V1)));
        dockerApiVersion.add(new HelpBubble("v1.help", "Support Docker V1 API"));
        dockerApiVersion.add(new Radio<>("v2", Model.of(DockerApiVersion.V2)));
        dockerApiVersion.add(new HelpBubble("v2.help", "Support Docker V2 API"));
        dockerSection.add(dockerApiVersion);
    } else if (repoDescriptor instanceof RemoteRepoDescriptor) {
        dockerSection.add(new StyledCheckbox("dockerTokenAuthentication")
                .setTitle("Enable Token Authentication").setEnabled(false));
        dockerSection.add(new SchemaHelpBubble("dockerTokenAuthentication.help"));
    }
    form.add(dockerSection);
}

From source file:org.efaps.ui.wicket.components.values.BooleanField.java

License:Apache License

/**
 * @param _wicketId wicket id for this component
 * @param _value value of this component
 * @param _choices choices/*from  www . j a v a  2s.  c o m*/
 * @param _fieldConfiguration configuration for this field
 * @param _label label for this field
 */
public BooleanField(final String _wicketId, final Object _value, final IModel<Map<Object, Object>> _choices,
        final FieldConfiguration _fieldConfiguration, final String _label, final boolean _uniqueName) {
    super(_wicketId, new Model<Boolean>());
    setOutputMarkupId(true);
    setRequired(_fieldConfiguration.getField().isRequired());
    this.fieldConfiguration = _fieldConfiguration;
    this.label = _label;
    // make a unique name if in a fieldset
    this.inputName = _fieldConfiguration.getName()
            + (_uniqueName ? "_" + RandomStringUtils.randomAlphabetic(4) : "");
    final RadioGroup<Boolean> radioGroup = new RadioGroup<Boolean>("radioGroup") {

        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;

        @Override
        public String getInputName() {
            return BooleanField.this.inputName;
        }
    };

    if (_value == null) {
        radioGroup.setDefaultModel(new Model<Boolean>());
    } else {
        radioGroup.setDefaultModel(Model.of((Boolean) _value));
    }
    add(radioGroup);
    final Iterator<Entry<Object, Object>> iter = _choices.getObject().entrySet().iterator();

    final Entry<Object, Object> first = iter.next();
    final Boolean firstVal = (Boolean) first.getValue();
    final Radio<Boolean> radio1 = new Radio<Boolean>("choice1", Model.of(firstVal), radioGroup) {

        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;

        @Override
        public String getValue() {
            return firstVal.toString();
        }
    };
    radio1.setLabel(Model.of((String) first.getKey()));
    radioGroup.add(radio1);
    final String markupId1 = radio1.getMarkupId(true);
    radioGroup.add(new Label("label1", Model.of((String) first.getKey())) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTag(final ComponentTag _tag) {
            super.onComponentTag(_tag);
            _tag.put("for", markupId1);
        }
    });

    final Entry<Object, Object> second = iter.next();
    final Boolean secondVal = (Boolean) second.getValue();
    final Radio<Boolean> radio2 = new Radio<Boolean>("choice2", Model.of(secondVal), radioGroup) {
        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;

        @Override
        public String getValue() {
            return secondVal.toString();
        }
    };
    radio2.setLabel(Model.of((String) second.getKey()));
    radioGroup.add(radio2);
    final String markupId2 = radio2.getMarkupId(true);
    radioGroup.add(new Label("label2", Model.of((String) second.getKey())) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTag(final ComponentTag _tag) {
            super.onComponentTag(_tag);
            _tag.put("for", markupId2);
        }
    });
}