You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by NoraBella <ne...@gmail.com> on 2011/07/06 12:24:27 UTC
Saving values of checked checkboxes in list
Hi, everybody!
I've read all the posts conserning compoundproperty model and checkboxes,
but didn't get the answer:
User on my site fullfilling form with diffrent dropdowns, checkboxes etc...
So i got a class for saving results:
*public class RequestEntity implements
IClusterable
{
private ResortsEntity resort;
private List starsList = new
ArrayList();
// getters & setters exist
}*
in html-page:
* <td width="130px">
Level of Hotel
<input wicket:id="checkbox"
type="checkbox" class="checkbox"/>
</td>*
and java-code:
* Form form = new Form("form", new
CompoundPropertyModel<RequestEntity>(requestEntity));
List<Integer> stars = new ArrayList<Integer>();
for (int i = 1; i < 6; i++)
stars.add(i);
ListView<Integer> starsList = new
ListView<Integer>("starsList", stars) {
protected void populateItem(ListItem<Integer>
item) {
item.add(new Checkbox("checkbox",
item.getModel()));
item.add(new Label("stars",
item.getModel()));
}
};
starsList.setOutputMarkupId(true);
form.add(starsList);
*
I want the results of checking to be saved in starList array in my compound
model... is it possible?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Saving-values-of-checked-checkboxes-in-list-tp3648239p3648239.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: Saving values of checked checkboxes in list
Posted by Martin Grigorov <mg...@apache.org>.
You need to use CheckGroup which will hold the list.
Each checkbox will be responsible for specific index in this list.
See http://www.wicket-library.com/wicket-examples/compref/wicket/bookmarkable/org.apache.wicket.examples.compref.CheckGroupPage
and its source code
On Wed, Jul 6, 2011 at 12:24 PM, NoraBella <ne...@gmail.com> wrote:
> Hi, everybody!
> I've read all the posts conserning compoundproperty model and checkboxes,
> but didn't get the answer:
>
> User on my site fullfilling form with diffrent dropdowns, checkboxes etc...
> So i got a class for saving results:
>
> *public class RequestEntity implements
> IClusterable
> {
> private ResortsEntity resort;
> private List starsList = new
> ArrayList();
>
> // getters & setters exist
> }*
>
> in html-page:
> * <td width="130px">
> Level of Hotel
>
> <input wicket:id="checkbox"
> type="checkbox" class="checkbox"/>
>
>
>
> </td>*
>
>
> and java-code:
> * Form form = new Form("form", new
> CompoundPropertyModel<RequestEntity>(requestEntity));
>
> List<Integer> stars = new ArrayList<Integer>();
> for (int i = 1; i < 6; i++)
> stars.add(i);
>
> ListView<Integer> starsList = new
> ListView<Integer>("starsList", stars) {
> protected void populateItem(ListItem<Integer>
> item) {
> item.add(new Checkbox("checkbox",
> item.getModel()));
> item.add(new Label("stars",
> item.getModel()));
> }
> };
>
> starsList.setOutputMarkupId(true);
> form.add(starsList);
> *
>
> I want the results of checking to be saved in starList array in my compound
> model... is it possible?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Saving-values-of-checked-checkboxes-in-list-tp3648239p3648239.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
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com