You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Artem001 <ar...@hys-enterprise.com> on 2012/08/10 17:08:50 UTC

RadioGroup

Hello there, mighty developers. 
I'm quite new in Wicket, so beforehand sorry if my question is stupid.
So what i have is a RadioGroup, with some childs. When page loads for the
first time, 
one of child gets selected by default, and everything is fine. But, when i
change selection and 
press submit button ( non-Ajax ), form validates,re-renders and "default"
child instead of selected one gets selection. 
What i'm doing wrong or not doing at all?

here is the example of how childs get populated :

SelectItem[] selectOneRadioItems = new SelectItem[]{};
RadioGroup radioGroup = new RadioGroup("radioGroup", new Model());
ListView<SelectItem> selectOneRadioListItems = new
ListView<SelectItem>("radioGroup", Arrays.asList(selectOneRadioItems)) {
      protected void populateItem(ListItem<SelectItem> item) {
	Label label = new Label("label", new
Model<String>(item.getModel().getObject().getLabel()));
	item.add(label);
	SelectItemModel<Serializable> itemModel = new
SelectItemModel<Serializable>(SelectItem)item.getModel().getObject());
	Radio<Serializable> radio = new Radio<Serializable>("radio", itemModel,
RadioGroupParent);
	item.add(radio);
}
};

Any tips will be appreciated. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioGroup-tp4651132.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: RadioGroup

Posted by Paul Bors <pa...@bors.ws>.
Have you taken a look at the Wicket-Examples project's component references
as linked from Wicket's website under the Learn section on the left panel?
http://www.wicket-library.com/wicket-examples/compref/

More specifically the RadioGroup and Radio:
http://www.wicket-library.com/wicket-examples/compref/wicket/bookmarkable/or
g.apache.wicket.examples.compref.RadioGroupPage?2

You need your form, then add to it a RadioGroup whose model holds on to the
active Radio selection and then add all the Radio buttons to the RadioGroup.

The RadioGroup can be a <span> tag and if I am not wrong even a
<wicket:container> tag.

Same concept applies to the CheckGroup and Check, not to be confused with
CheckBox.

Hope that helps!

~ Thank you,
  Paul Bors

PS: Since Wicket is open source, you can download those projects including
wicket-examples and run them locally on your computer. See the "Provide a
path" link from under the Contribute section on the left panel of the home
page an then follow the "Check out the code" link.

-----Original Message-----
From: Andrea Del Bene [mailto:an.delbene@gmail.com] 
Sent: Saturday, August 11, 2012 3:48 PM
To: users@wicket.apache.org
Subject: Re: RadioGroup

Ok, but I still don't understand the relation between RadioGroup and the
Radio controls you create. I mean, I expect to find a section of the code
where you add Radio controls to RadioGroup (they "have to be in the
component hierarchy somewhere below the group component" as stated into
JavaDoc)
> Hi Andrea,
> ListView is only renderer for Radio elements,  in real life 
> selectOneRadioItems isn't empty array. Code little bit difficult to 
> understand. But problem it setting model value after form submission 
> RadioGroup instance didn't put value to model, but on rendering phase 
> it reading data from model.
> Wicket version 1.5.7.
> Valery Gorbunov
> On Sat, Aug 11, 2012 at 12:12 AM, Andrea Del Bene
<an...@gmail.com>wrote:
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RadioGroup

Posted by Andrea Del Bene <an...@gmail.com>.
Ok, but I still don't understand the relation between RadioGroup and the 
Radio controls you create. I mean, I expect to find a section of the 
code where you add Radio controls to RadioGroup (they "have to be in the 
component hierarchy somewhere below the group component" as stated into 
JavaDoc)
> Hi Andrea,
> ListView is only renderer for Radio elements,  in real
> life selectOneRadioItems isn't empty array. Code little bit difficult to
> understand. But problem it setting model value after form submission
> RadioGroup instance didn't put value to model, but on rendering phase it
> reading data from model.
> Wicket version 1.5.7.
> Valery Gorbunov
> On Sat, Aug 11, 2012 at 12:12 AM, Andrea Del Bene <an...@gmail.com>wrote:
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RadioGroup

Posted by Valery Gorbunov <va...@hys-enterprise.com>.
Hi Andrea,
ListView is only renderer for Radio elements,  in real
life selectOneRadioItems isn't empty array. Code little bit difficult to
understand. But problem it setting model value after form submission
RadioGroup instance didn't put value to model, but on rendering phase it
reading data from model.
Wicket version 1.5.7.
Valery Gorbunov
On Sat, Aug 11, 2012 at 12:12 AM, Andrea Del Bene <an...@gmail.com>wrote:

> Hi and welcome to this mailing list!
>
> it's not clear to me the purpose of the ListView in your code. Why do you
> need it and what is the relation between this component and RadioGroup?
>
>> Hello there, mighty developers.
>> I'm quite new in Wicket, so beforehand sorry if my question is stupid.
>> So what i have is a RadioGroup, with some childs. When page loads for the
>> first time,
>> one of child gets selected by default, and everything is fine. But, when i
>> change selection and
>> press submit button ( non-Ajax ), form validates,re-renders and "default"
>> child instead of selected one gets selection.
>> What i'm doing wrong or not doing at all?
>>
>> here is the example of how childs get populated :
>>
>> SelectItem[] selectOneRadioItems = new SelectItem[]{};
>> RadioGroup radioGroup = new RadioGroup("radioGroup", new Model());
>> ListView<SelectItem> selectOneRadioListItems = new
>> ListView<SelectItem>("**radioGroup", Arrays.asList(**selectOneRadioItems))
>> {
>>        protected void populateItem(ListItem<**SelectItem> item) {
>>         Label label = new Label("label", new
>> Model<String>(item.getModel().**getObject().getLabel()));
>>         item.add(label);
>>         SelectItemModel<Serializable> itemModel = new
>> SelectItemModel<Serializable>(**SelectItem)item.getModel().**
>> getObject());
>>         Radio<Serializable> radio = new Radio<Serializable>("radio",
>> itemModel,
>> RadioGroupParent);
>>         item.add(radio);
>> }
>> };
>>
>> Any tips will be appreciated.
>>
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.**
>> n4.nabble.com/RadioGroup-**tp4651132.html<http://apache-wicket.1842946.n4.nabble.com/RadioGroup-tp4651132.html>
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: RadioGroup

Posted by Andrea Del Bene <an...@gmail.com>.
Hi and welcome to this mailing list!

it's not clear to me the purpose of the ListView in your code. Why do 
you need it and what is the relation between this component and RadioGroup?
> Hello there, mighty developers.
> I'm quite new in Wicket, so beforehand sorry if my question is stupid.
> So what i have is a RadioGroup, with some childs. When page loads for the
> first time,
> one of child gets selected by default, and everything is fine. But, when i
> change selection and
> press submit button ( non-Ajax ), form validates,re-renders and "default"
> child instead of selected one gets selection.
> What i'm doing wrong or not doing at all?
>
> here is the example of how childs get populated :
>
> SelectItem[] selectOneRadioItems = new SelectItem[]{};
> RadioGroup radioGroup = new RadioGroup("radioGroup", new Model());
> ListView<SelectItem> selectOneRadioListItems = new
> ListView<SelectItem>("radioGroup", Arrays.asList(selectOneRadioItems)) {
>        protected void populateItem(ListItem<SelectItem> item) {
> 	Label label = new Label("label", new
> Model<String>(item.getModel().getObject().getLabel()));
> 	item.add(label);
> 	SelectItemModel<Serializable> itemModel = new
> SelectItemModel<Serializable>(SelectItem)item.getModel().getObject());
> 	Radio<Serializable> radio = new Radio<Serializable>("radio", itemModel,
> RadioGroupParent);
> 	item.add(radio);
> }
> };
>
> Any tips will be appreciated.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/RadioGroup-tp4651132.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org