List of usage examples for org.apache.wicket.markup.html.form Radio getMarkupId
public String getMarkupId()
From source file:com.userweave.pages.components.twoColumnPanel.multiColumnRadioChoicePanel.RadioChoiceColumnPanel.java
License:Open Source License
public RadioChoiceColumnPanel(String id, IModel model, IChoiceRenderer renderer) { super(id);/*from w ww. ja v a2s. c o m*/ Radio radio = new Radio("radio", model); radio.setOutputMarkupId(true); add(radio); Label label = new Label("label", getLabel(this, model, renderer)); label.add(new AttributeModifier("for", new Model<String>(radio.getMarkupId()))); add(label); }
From source file:de.alpharogroup.wicket.components.examples.radios.RadioGroupExamplePanel.java
License:Apache License
public RadioGroupExamplePanel(final String id, final IModel<Company> model) { super(id, model); // Radio buttons have to be part of a Form component. final Form<?> form = new Form<>("form"); add(form);/*w ww.j av a2 s.c om*/ final RadioGroupModelBean<Company> radioGroupModel = new RadioGroupModelBean<>(); setModel(model); // create list... final List<Company> comps = Arrays.asList(Company.builder().name("Ferrari").build(), Company.builder().name("Lamborgini").build(), Company.builder().name("Mazerati").build(), Company.builder().name("Porsche").build()); // we can set the selected radio from the start or leave it blank... // radioGroupModel.setSelected(comps.get(0)); radioGroupModel.setRadios(comps); final IModel<List<Company>> companies = new ListModel<Company>(comps); final RadioGroup<Company> group = new RadioGroup<Company>("group", new PropertyModel<Company>(radioGroupModel, "selected")); group.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.add(getFeedback()); info("Selected Type : " + radioGroupModel.getSelected()); } }); form.add(group); // Construct a radio button and label for each company. group.add(new ListView<Company>("choice", companies) { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Company> it) { final Radio<Company> radio = new Radio<Company>("radio", it.getModel(), group); radio.setOutputMarkupId(true); it.add(radio); it.add(ComponentFactory.newLabel("label", radio.getMarkupId(), Model.of(it.getModelObject().getName()))); } }); final RadioGroupPanel<Company> radioGroupPanel = new RadioGroupPanel<Company>("radioGroupPanel", Model.of(radioGroupModel)) { /** * The serialVersionUID */ private static final long serialVersionUID = 1L; @Override protected void onUpdate(final AjaxRequestTarget target) { super.onUpdate(target); target.add(getFeedback()); info("Selected Type : " + radioGroupModel.getSelected()); } }; add(radioGroupPanel); }
From source file:de.alpharogroup.wicket.components.radio.RadioGroupPanel.java
License:Apache License
/** * Factory method for create the new {@link ListView} for the {@link Radio} objects. This method * is invoked in the constructor from the derived classes and can be overridden so users can * provide their own version of a new {@link ListView} for the {@link Radio} objects. * * @param id//from w ww .ja va 2 s . co m * the id * @param model * the model * @return the new {@link ListView} for the {@link Radio} objects. */ protected ListView<T> newRadioListView(final String id, final IModel<RadioGroupModelBean<T>> model) { final ListView<T> radioListView = new ListView<T>("choice", model.getObject().getRadios()) { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; /** * {@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())); } }; radioListView.setOutputMarkupId(true); return radioListView; }
From source file:net.dontdrinkandroot.extensions.wicket.component.jqueryui.JQueryUiAjaxRadioChoice.java
License:Apache License
public JQueryUiAjaxRadioChoice(String id, IModel<T> model, IModel<? extends List<T>> choices, IChoiceRenderer<? super T> renderer) { super(id, model); this.setOutputMarkupId(true); this.choices = choices; this.setChoiceRenderer(renderer); final RadioGroup<T> radioGroup = new RadioGroup<T>("radioGroup", model); this.add(radioGroup); final ListView<T> radioItemView = new ListView<T>("radioItem", choices) { private static final long serialVersionUID = 1L; @Override// ww w. ja v a 2s . c o m protected void populateItem(final ListItem<T> item) { final Radio<T> radio = new Radio<T>("input", item.getModel(), radioGroup); radio.setOutputMarkupId(true); radio.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { JQueryUiAjaxRadioChoice.this.onSelectionChanged(item.getModelObject(), target); } }); item.add(radio); final Label label = new Label("label", JQueryUiAjaxRadioChoice.this.getChoiceRenderer() .getDisplayValue(item.getModel().getObject()).toString()); label.add(new AttributeAppender("for", new Model<String>(radio.getMarkupId()))); item.add(label); item.setRenderBodyOnly(true); } }; radioGroup.add(radioItemView); }
From source file:net.dontdrinkandroot.wicket.component.jqueryui.JQueryUiAjaxRadioChoice.java
License:Apache License
public JQueryUiAjaxRadioChoice(String id, IModel<T> model, IModel<? extends List<? extends T>> choices, IChoiceRenderer<? super T> renderer) { super(id, model); this.setOutputMarkupId(true); this.choices = choices; this.setChoiceRenderer(renderer); final RadioGroup<T> radioGroup = new RadioGroup<T>("radioGroup", model); this.add(radioGroup); ListView<T> radioItemView = new ListView<T>("radioItem", choices) { private static final long serialVersionUID = 1L; @Override//from ww w . j a v a 2 s.c om protected void populateItem(final ListItem<T> item) { Radio<T> radio = new Radio<T>("input", item.getModel(), radioGroup); radio.setOutputMarkupId(true); radio.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { JQueryUiAjaxRadioChoice.this.onSelectionChanged(item.getModelObject(), target); } }); item.add(radio); Label label = new Label("label", JQueryUiAjaxRadioChoice.this.getChoiceRenderer() .getDisplayValue(item.getModel().getObject()).toString()); label.add(new AttributeAppender("for", new Model<String>(radio.getMarkupId()))); item.add(label); item.setRenderBodyOnly(true); } }; radioGroup.add(radioItemView); }
From source file:net.kornr.swit.site.widget.AjaxImageRadio.java
License:Apache License
public AjaxImageRadio(String id, ResourceReference resourceReference, ValueMap resourceParameters, Form form, Radio radio) { super(id, resourceReference, resourceParameters); radio.setOutputMarkupId(true);// ww w . ja v a 2 s . c om m_radioId = radio.getMarkupId(); this.add(new AjaxFormSubmitBehavior(form, "onclick") { @Override protected void onError(AjaxRequestTarget arg0) { } @Override protected void onSubmit(AjaxRequestTarget target) { AjaxImageRadio.this.onSubmit(target); } @Override protected CharSequence getEventHandler() { String seq = "$('#" + m_radioId + "').attr('checked',true);"; return seq + super.getEventHandler(); } }); }
From source file:org.cast.cwm.data.component.StarPanel.java
License:Open Source License
/** * Constructor. If the model object is null, this component will be invisible. * //from w ww. ja v a 2 s .c om * TODO: This hiding behavior is not ideal or expected. Only used because this is * both a viewer and editor. * * @param id * @param model */ public StarPanel(String id, IModel<Response> model) { super(id, model); setOutputMarkupId(true); add(AttributeModifier.append("class", "starPanel")); if (model == null || model.getObject() == null) { setVisible(false); return; } if (!model.getObject().getType().equals(typeRegistry.getResponseType("STAR_RATING"))) throw new IllegalArgumentException( "A Star Rating panel must be attached to a ResponseType.STAR_RATING."); Form<Response> form = new Form<Response>("starForm", getModel()) { private static final long serialVersionUID = 1L; @Override public void onSubmit() { responseService.saveStarRating(getModel(), Integer.valueOf(radioGroup.getValue()).intValue()); } }; add(form); radioGroup = new RadioGroup<Integer>("radioGroup", new Model<Integer>()); // Model set in onBeforeRender() form.add(radioGroup); // TODO: This markup is not the best for accessibility. The label should come after the radio, not wrap it. However // changing would take a lot of work in the javascript. RepeatingView rv = new RepeatingView("radioRepeatingView"); radioGroup.add(rv); for (int i = 1; i <= numStars; i++) { WebMarkupContainer item = new WebMarkupContainer(rv.newChildId()); rv.add(item); Radio<Integer> radio = new Radio<Integer>("radio", new Model<Integer>(i)); radio.setOutputMarkupId(true); Label label = new Label("label", i == 1 ? i + " Star" : i + " Stars"); label.setRenderBodyOnly(true); item.add(AttributeModifier.replace("for", radio.getMarkupId())); item.add(radio); item.add(label); } form.add(new DisablingIndicatingAjaxButton("submitButton") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(target); target.add(StarPanel.this); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { onError(target, form); } @Override protected Collection<? extends Component> getComponents() { return Arrays.asList(StarPanel.this); } }); }
From source file:org.wicketstuff.datatable_autocomplete.table.column.DTARadioColumn.java
License:Apache License
/** * Get the markupid for the radio representing a specific row. Used to allow row onclick actions * to trigger a radio selection DOM action. * //from ww w . ja va 2 s.co m * @param index * @return the markup id for the radio for the row index given. */ public final String getRadioMarkupID(int index) { Radio<T> radio = radioList.get(index); if (radio == null) return null; else return radio.getMarkupId(); }