that iterator you added has no much sense, as it represents only an item on the list, but not the list itself. moreover you don't need modifying components, but updating their models, as mentioned in mail before (may you study wicket models a bit more... see https://cwiki.apache.org/WICKET/working-with-wicket-models.html)
may you apply OnChangeAjaxBehaviour on each checkbox, instead of adding a CheckGroup. here's the code before, modified to work as you need, deselecting other checkboxes when current one is selected: [2] java: public class CheckBoxListPage extends WebPage { private Form inputForm; public CheckBoxListPage() { final FeedbackPanel feedback = new FeedbackPanel("feedback"); add(feedback); add(inputForm = new InputForm("inputForm")); } /** form for processing the input. */ private class InputForm extends Form { // holds NameWrapper elements private List<NameWrapper> data; public InputForm(String name) { super(name); // add some dummy data data = new ArrayList<NameWrapper>(); data.add(new NameWrapper("one")); data.add(new NameWrapper("two")); data.add(new NameWrapper("three")); data.add(new NameWrapper("four")); // add a nested list view; as the list is nested in the form, the form will // update all FormComponent childs automatically. final ListView<NameWrapper> listView = new ListView<NameWrapper>("list", data) { protected void populateItem(ListItem<NameWrapper> item) { final NameWrapper wrapper = (NameWrapper)item.getModelObject(); item.add(new Label("name", wrapper.getName())); final CheckBox checkBox = new CheckBox("check", new PropertyModel<Boolean>(wrapper, "selected")); item.add(checkBox); checkBox.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { if (wrapper.getSelected()) { for (NameWrapper entity : data) { if (!entity.equals(wrapper)) { entity.setSelected(Boolean.FALSE); } } } target.addComponent(inputForm); } }); } }; listView.setReuseItems(true); add(listView); } public void onSubmit() { info("data: " + data); // print current contents } } On Mon, Sep 26, 2011 at 12:06 PM, wholalotta <ardaas...@gmail.com> wrote: > I tried the following but couldnt get into "onUpdate" method while debugging. > I need to use checkgroup to be able to use > AjaxFormChoiceComponentUpdatingBehavior. So I created a checkgroup and added > the checkboxes into it. So I guess in each iteration I am creating one text > area, one check group and one checkbox that is attached to that checkgroup. > What I am trying to do is when I select a checkbox, I want to re-render only > the checkboxes by iterating the item list one by one. But it seems if I do > this I need to add ajaxbehaviour on to listview?? I think what I am trying > to do in here is a little bit tricky and this is not Listview is created for > am i right? I am definitely stucked. If I dont use Listview, I need to do > this by putting more lines of code and I dont want to do that. > > ListView listView = new ListView("list", data) > { > > @Override > protected void populateItem(final ListItem item) { > NameWrapper wrapper = > (NameWrapper)item.getModelObject(); > item.add(new TextArea("name", new > PropertyModel(wrapper, "name"))); > final CheckGroup checkgroup = new CheckGroup > ("checkgroup", new PropertyModel(wrapper, "selected")); > item.add(checkgroup); > CheckBox check = new CheckBox("checkbox",new > Model()); > checkgroup.setOutputMarkupId(true); > checkgroup.add(check); > checkgroup.add(new > AjaxFormChoiceComponentUpdatingBehavior() { > @Override > protected void onUpdate(AjaxRequestTarget > target) { > info("We are here"); > for (Iterator iter = item.iterator(); > iter.hasNext();) { > > // FIND THE SELECTED ONE and DE-SELECT > the OTHER CHECKBOXES in the list > } > target.addComponent(checkgroup); > } > }); > } > }; > listView.setReuseItems(true); > add(listView); > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/creating-a-textarea-with-a-radiobutton-using-Listview-tp3829602p3843288.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org