/** * Factory method for create a new {@link RadioChoice}. * * @param <T> * the generic type of the model * @param id * the id * @param model * the model * @param choices * The list of choices in the radio choice * @return the new {@link RadioChoice} */ public static <T> RadioChoice<T> newRadioChoice(final String id, final IModel<T> model, final List<? extends T> choices) { final RadioChoice<T> radioChoice = new RadioChoice<>(id, model, choices); radioChoice.setOutputMarkupId(true); return radioChoice; }
/** * @see org.apache.wicket.Component#onComponentTagBody(MarkupStream, ComponentTag) */ @Override public final void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { // Iterate through choices final List<? extends T> choices = getChoices(); // Buffer to hold generated body final AppendingStringBuffer buffer = new AppendingStringBuffer((choices.size() + 1) * 70); // The selected value final String selected = getValue(); // Loop through choices for (int index = 0; index < choices.size(); index++) { // Get next choice final T choice = choices.get(index); appendOptionHtml(buffer, choice, index, selected); } // Replace body replaceComponentTagBody(markupStream, openTag, buffer); }
/** * @see org.apache.wicket.version.undo.Change#undo() */ public void undo() { setSuffix(prevSuffix); }
final List<? extends T> choices = getChoices(); final String selected = getValue(); Object displayValue = getChoiceRenderer().getDisplayValue(choice); Class<?> objectClass = (displayValue == null ? null : displayValue.getClass()); final IConverter converter = getConverter(objectClass); label = converter.convertToString(displayValue, getLocale()); buffer.append(getPrefix()); String id = getChoiceRenderer().getIdValue(choice, index); final String idAttr = getMarkupId() + "-" + id; boolean enabled = isEnabledInHierarchy() && !isDisabled(choice, index, selected); .append(getInputName()) .append("\"") .append(" type=\"radio\"") .append((isSelected(choice, index, selected) ? " checked=\"checked\"" : "")) .append((enabled ? "" : " disabled=\"disabled\"")) .append(" value=\"") if (wantOnSelectionChangedNotifications()) CharSequence url = urlFor(IOnChangeListener.INTERFACE); Form<?> form = findParent(Form.class);
final List choices = getChoices(); final String selected = getValue(); Object displayValue = getChoiceRenderer().getDisplayValue(choice); Class objectClass = displayValue == null ? null : displayValue.getClass(); label = getConverter(objectClass).convertToString(displayValue, getLocale()); buffer.append(getPrefix()); String id = getChoiceRenderer().getIdValue(choice, index); final String idAttr = getInputName() + "_" + id; .append(getInputName()) .append("\"") .append(" type=\"radio\"") .append((isSelected(choice, index, selected) ? " checked=\"checked\"" : "")) .append((isEnabled() ? "" : " disabled=\"disabled\"")) .append(" value=\"") .append(id) if (wantOnSelectionChangedNotifications()) CharSequence url = urlFor(IOnChangeListener.INTERFACE); Form form = (Form)findParent(Form.class); if (form != null)
Object displayValue = getChoiceRenderer().getDisplayValue(choice); Class<?> objectClass = (displayValue == null ? null : displayValue.getClass()); final IConverter converter = getConverter(objectClass); label = converter.convertToString(displayValue, getLocale()); buffer.append(getPrefix(index, choice)); String id = getChoiceRenderer().getIdValue(choice, index); final String idAttr = getMarkupId() + "-" + id; boolean enabled = isEnabledInHierarchy() && !isDisabled(choice, index, selected); if (localizeDisplayValues()) display = getLocalizer().getString(label, this, label); if (getEscapeModelStrings()) IValueMap labelAttrs = getAdditionalAttributesForLabel(index, choice); StringBuilder extraLabelAttributes = new StringBuilder(); if (labelAttrs != null) .append(getInputName()) .append('"') .append(" type=\"radio\"") .append((isSelected(choice, index, selected) ? " checked=\"checked\"" : "")) .append((enabled ? "" : " disabled=\"disabled\"")) .append(" value=\"")
= new RadioChoice("catalogMode", CATALOG_MODES, new CatalogModeRenderer()); catalogModeChoice.setSuffix(" "); form.add(catalogModeChoice);
buffer.append(getPrefix(index, choice)); String id = getChoiceRenderer().getIdValue(choice, index); final String idAttr = getMarkupId() + "-" + id; boolean enabled = isEnabledInHierarchy() && !isDisabled(choice, index, selected); CharSequence renderValue = renderValue(choice); IValueMap labelAttrs = getAdditionalAttributesForLabel(index, choice); StringBuilder extraLabelAttributes = new StringBuilder(); if (labelAttrs != null) .append(getInputName()) .append('"') .append(" type=\"radio\"") .append((isSelected(choice, index, selected) ? " checked=\"checked\"" : "")) .append((enabled ? "" : " disabled=\"disabled\"")) .append(" value=\"") IValueMap attrs = getAdditionalAttributes(index, choice); if (attrs != null) DebugSettings debugSettings = getApplication().getDebugSettings(); String componentPathAttributeName = debugSettings.getComponentPathAttributeName(); if (Strings.isEmpty(componentPathAttributeName) == false) CharSequence path = getPageRelativePath(); path = Strings.replaceAll(path, "_", "__");
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
new ResourceModel("AdminPage.export.only.schema").getObject().toString()); content = (String)contentCategories.get(0); RadioChoice<String> contentRadioChoice = new RadioChoice<String>("content", new PropertyModel<String>(this, "content"), contentCategories); contentRadioChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { RadioChoice<String> syntaxRadioChoice = new RadioChoice<String>("syntax", new PropertyModel<String>(this, "syntax"), syntaxCategories, new IChoiceRenderer<String>() { public Object getDisplayValue(String object) { syntaxRadioChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { new ResourceModel("AdminPage.export.view").getObject().toString()); action = actionCategories.get(0).toString(); RadioChoice<String> actionRadioChoice = new RadioChoice<String>("action", new PropertyModel<String>(this, "action"), actionCategories); form.add(actionRadioChoice); actionRadioChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) {
/** * @param prefix * Prefix to use before choice * @return this */ public final RadioChoice<T> setPrefix(String prefix) { // Tell the page that this component's prefix was changed addStateChange(); this.prefix = prefix; return this; }
add(projectType = (RadioChoice<Mode>) new RadioChoice<Mode>("mode", Arrays.asList(new Mode[] { Mode.ANNOTATION, Mode.AUTOMATION, Mode.CORRECTION })) .setEnabled(projectDetailForm.getModelObject().getId() == 0)); add(new Button("save", new ResourceModel("label"))
= new RadioChoice("catalogMode", CATALOG_MODES, new CatalogModeRenderer()); catalogModeChoice.setSuffix(" "); form.add(catalogModeChoice);
@Override public void onSubmit() { try { DataAccessRuleDAO dao = DataAccessRuleDAO.get(); CatalogMode newMode = dao.getByAlias(catalogModeChoice.getValue()); dao.setCatalogMode(newMode); dao.storeRules(); doReturn(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error occurred while saving user", e); error(new ParamResourceModel("saveError", getPage(), e.getMessage())); } } });
new ResourceModel("AdminPage.export.only.schema").getObject().toString()); content = (String)contentCategories.get(0); RadioChoice<String> contentRadioChoice = new RadioChoice<String>("content", new PropertyModel<String>(this, "content"), contentCategories); contentRadioChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { RadioChoice<String> syntaxRadioChoice = new RadioChoice<String>("syntax", new PropertyModel<String>(this, "syntax"), syntaxCategories, new IChoiceRenderer<String>() { @Override syntaxRadioChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { new ResourceModel("AdminPage.export.view").getObject().toString()); action = actionCategories.get(0).toString(); RadioChoice<String> actionRadioChoice = new RadioChoice<String>("action", new PropertyModel<String>(this, "action"), actionCategories); form.add(actionRadioChoice); actionRadioChoice.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) {
/** * @param prefix * Prefix to use before choice * @return this */ public final RadioChoice<T> setPrefix(String prefix) { // Tell the page that this component's prefix was changed addStateChange(); this.prefix = prefix; return this; }
new RadioChoice("catalogMode", CATALOG_MODES, new CatalogModeRenderer()); catalogModeChoice.setSuffix(" "); form.add(catalogModeChoice);
/** * Factory method for create a new {@link RadioChoice}. * * @param <T> * the generic type of the model * @param id * the id * @param model * the model * @param choices * The list of choices in the radio choice * @return the new {@link RadioChoice} */ public static <T> RadioChoice<T> newRadioChoice(final String id, final IModel<T> model, final List<? extends T> choices) { final RadioChoice<T> radioChoice = new RadioChoice<T>(id, model, choices); radioChoice.setOutputMarkupId(true); return radioChoice; }