protected Radio<T> newRadio(String id, IModel<T> model, RadioGroup<T> radioGroup) { return new Radio<T>(id, model, radioGroup); }
@Override protected String load() { StringBuffer template = new StringBuffer(); template.append("if ("); for (int i = 0; i < radioList.size(); i++) { Radio radio = radioList.get(i); template.append ("(Wicket.$('"+ radio.getMarkupId(true) +"').checked == false)"); if (i > 0 && (i < (radioList.size()-1))) { template.append (" and "); } radio.setOutputMarkupId(true); } template.append("{" + "\nalert ('A selected row is required.');" + "\nreturn false;" + "\n}"); return template.toString(); }
public RadioButtonLabelPanel<T> setSubmitOnChange() { radioButton.add(AttributeModifier.replace("onchange", "javascript:submit();")); return this; } }
private String getFormComponentValue(final Radio<?> formComponent) { boolean oldEscape = formComponent.getEscapeModelStrings(); formComponent.setEscapeModelStrings(false); String val = formComponent.getValue(); formComponent.setEscapeModelStrings(oldEscape); return val; } });
public class MyRenderer implements GridCellRenderer { public Radio render(ModelData model, String columnChoice, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid) { Something something = ((Something) model).getSomething(); Radio radio = new Radio(); // we want one radioGroup per row: radio.setName("radioButton" + rowIndex); // set value depending on some property in the model corresponding to a // column if (something != null && something.getChoice().equals(columnChoice)) { radio.setValue(true); } return radio; } }
/** * {@inheritDoc} */ @Override protected void populateItem(final ListItem<T> item) { final Radio<T> radio = new Radio<>("radio", item.getModel(), RadioGroupPanel.this.group); radio.setOutputMarkupId(true); item.add(radio); item.add( RadioGroupPanel.this.newLabel("label", radio.getMarkupId(), item.getModel())); } };
@Override protected void populateItem(ListItem<T> item) { final Radio<T> radio = new Radio<T>("radio", item.getModel()); radio.add(new AjaxEventBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { group.processInput(); onChange(target, group.getModelObject()); } @Override protected CharSequence getEventHandler() { return generateCallbackScript(new AppendingStringBuffer("wicketAjaxPost('").append( getCallbackUrl()).append( "', wicketSerialize(document.getElementById('" + radio.getMarkupId() + "'))")); } }); item.add(radio); String label = item.getDefaultModelObjectAsString(); radio.setLabel(new Model<String>(getLocalizer().getString(label, this, label))); item.add(new SimpleFormComponentLabel("label", radio)); RadioGroupWidget.this.populateItem(item); } });
protected void populateItem(final ListItem item) final Radio radio = new Radio("selection", new Model(item.getModelObject().toString())); final Label label = new Label("name", new Model(item.getModelObject().toString())); radio.setOutputMarkupId(true); radio.setOutputMarkupPlaceholderTag(true); item.add(radio); item.add(label); item.setOutputMarkupId(true); radio.add(new AjaxEventBehavior("onclick")
public Radio<T> add(final Model<T> model, final String labelString, final String tooltip) { final WebMarkupContainer cont = new WebMarkupContainer(repeater.newChildId()); repeater.add(cont); final Radio<T> radio = new Radio<T>("radio", model, radioGroup); if (autosubmit == true) { radio.add(AttributeModifier.replace("onchange", "javascript:submit();")); } cont.add(radio); final Label label = new Label("label", labelString); label.add(AttributeModifier.replace("for", radio.setOutputMarkupId(true).getMarkupId())); label.setRenderBodyOnly(true); cont.add(label); if (tooltip != null) { WicketUtils.addTooltip(label, tooltip); } return radio; }
checkComponentTag(tag, "input"); checkComponentTagAttribute(tag, "type", "radio"); final String value = getValue(); RadioGroup<?> group = getGroup(); else if (group.getModelComparator().compare(group, getDefaultModelObject())) if (!isEnabledInHierarchy())
public RadioButtonLabelPanel(final String id, final IModel<T> model, final String label) { super(id); radioButton = new Radio<T>("radioButton", model); add(radioButton); final Model<String> labelModel = new Model<String>(label); radioButton.setLabel(labelModel); // I18n key must be implemented as Model not as String because in constructor (before adding this component to parent) a warning will be // logged for using getString(String). add(new Label("label", labelModel).add(AttributeModifier.replace("for", radioButton.getMarkupId()))); setRenderBodyOnly(true); }
@Override protected void populateItem(ListItem item) { final Serializable radioitem = (Serializable) item.getModelObject(); final Radio rc = new Radio("radiochoice", new Model(radioitem)); // Must use AjaxFormSubmitBehavior for this type of component rc.add(new AjaxFormSubmitBehavior(form, "onclick") { protected void onSubmit(AjaxRequestTarget target) { if(target != null) { int size = ajaxTargets.size(); for (int i = 0; i < size; i++) { target.addComponent(ajaxTargets.get(i)); } } } @Override protected void onError(AjaxRequestTarget target) { } }); // Add label for radio button String label = radioitem.toString(); String display = label; if (localizeDisplayValues()) { display = getLocalizer().getString(label, this, label); } item.add(rc); item.add(new Label("radiolabel", display)); item.add(new Label("suffix", getSuffix()).setRenderBodyOnly(true).setEscapeModelStrings(false)); } });
protected void init() { super.add(ResourcePackage.forJavaScript(StyledRadio.class)); super.add(new CssClass("styled-checkbox")); radio = new Radio<>("radio", new DelegatedModel<T>(this)); radio.setOutputMarkupId(true); add(radio); button = new RadioButton("button"); add(button); }
@Override protected void populateItem(ListItem<ButtonElement<T>> item) { ButtonElement<T> buttonElement = item.getModelObject(); Radio<T> radio = newRadio("buttonRadio", buttonElement.getModel(), radioGroup); radio.setLabel(buttonElement.getLabel()); radio.setOutputMarkupId(true); SimpleFormComponentLabel label = new SimpleFormComponentLabel("buttonRadioLabel", radio); item.add(radio); item.add(label); } };
checkComponentTag(tag, "input"); checkComponentTagAttribute(tag, "type", "radio"); final String value = getValue(); RadioGroup group = (RadioGroup)findParent(RadioGroup.class); if (group == null) getPath() + "] cannot find its parent RadioGroup. All Radio components must be a child of or below in the hierarchy of a RadioGroup component."); else if (Objects.equal(group.getModelObject(), getModelObject())) if (!isActionAuthorized(ENABLE) || !isEnabled() || !group.isEnabled())
formPanel.add(fieldSet); final Radio moveRadio = new Radio(); moveRadio.setName("dropstyle"); moveRadio.setBoxLabel("Move"); moveRadio.setChecked(true); fieldSet.add(moveRadio); final Radio copyRadio = new Radio(); copyRadio.setName("dropstyle"); copyRadio.setBoxLabel("Copy"); fieldSet.add(copyRadio); DropNodeCallback dropDropNodeCallback) { if ("true".equals(target.getAttribute("trip"))) { if (copyRadio.getValue()) { TreeNode copyNode = dropNode.cloneNode(); Node[] children = copyNode.getChildNodes();
/** * @param id * @param model * @param group * parent {@link RadioGroup} * @see WebMarkupContainer#WebMarkupContainer(String, IModel) */ public Radio(final String id, final IModel<T> model, final RadioGroup<T> group) { super(id, model); this.group = group; setOutputMarkupId(true); }
public Object component(Component component) { if (component instanceof Radio) { final Radio radio = (Radio)component; if (radio.getValue().equals(value)) { return radio; } } return CONTINUE_TRAVERSAL; }
@Override public void component(Radio<T> radio, IVisit<String> visit) { if (getModelComparator().compare(RadioGroup.this, radio.getDefaultModelObject())) { visit.stop(radio.getValue()); } } });