You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Merlijn <lu...@gmail.com> on 2013/04/30 12:45:41 UTC
Saving checked choices from CheckGroup
Hi everybody,
I am making a filter for a searchfield where users can choose which items
they want to choose. For this I am using a CheckGroup to show all the
options. Now, whenever I choose an item and use the submit button, the other
items get removed from the list. How can I make sure that the checked
choices get remembered and the non-checked kept in the list?
Kind regards,
Merlijn
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Saving-checked-choices-from-CheckGroup-tp4658408.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 checked choices from CheckGroup
Posted by Merlijn <lu...@gmail.com>.
Well, the first problem is solved :)
I just want to be able to check a number of checkboxes and use the list of
values that correspond with the values of the Checks in another panel. I
currently have the following but does not seem to work. I also do not want
to use AjaxFormChoiceUpdatingBehaviour as it otherwise does a post whenever
someone checks or unchecks an item.
public QuickSearchFilterPanel(String id) {
super(id);
form = new Form("filterform");
types = resultItemHandlerPool.getTypes();
checkGroup = new CheckGroup<Class<?>>("checkGroup", new
ArrayList<Class<?>>());
ListView typesListview = new ListView<Class<?>>("typesList",
resultItemHandlerPool.getTypes()) {
@Override
protected void populateItem(final ListItem<Class<?>> item) {
Check c = new Check<Class<?>>("check", item.getModel());
item.add(c);
item.add(new Label("className",
item.getModelObject().getSimpleName()));
}
};
typesListview.setReuseItems(true);
checkGroup.add(typesListview);
form.add(checkGroup);
add(form);
}
public List<Class<?>> getSearchableTypes() {
return types;
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Saving-checked-choices-from-CheckGroup-tp4658408p4658490.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 checked choices from CheckGroup
Posted by Paul Bors <pa...@bors.ws>.
Create a QuickStart and share it with us.
~ Thank you,
Paul Bors
On Tue, Apr 30, 2013 at 7:17 AM, Merlijn <lu...@gmail.com> wrote:
> Nope, added in the code. This is my code
>
> public QuickSearchFilterPanel(String id) {
> super(id);
> Form form = new Form("filterform");
>
> List<Class<?>> classes = resultItemHandlerPool.getTypes();
> types = new ArrayList<IModel<Class<?>>>();
>
> if (classes != null) {
> for (final Class<?> clazz : classes) {
> IModel<Class<?>> model = new IModel<Class<?>>() {
> @Override
> public Class<?> getObject() {
> return clazz;
> }
>
> @Override
> public void setObject(Class<?> object) {
>
> }
>
> @Override
> public void detach() {
>
> }
> };
>
> types.add(model);
> }
> }
>
> group = new CheckGroup<IModel<Class<?>>>("checkboxgroup", new
> PropertyModel<Collection<IModel<Class<?>>>>(this, "types"));
> group.add(new CheckGroupSelector("checkall"));
>
> ListView typesListview = new
> ListView<IModel<Class<?>>>("typesList", new
> PropertyModel<List<IModel<Class<?>>>>(this, "types")) {
> @Override
> protected void populateItem(final
> ListItem<IModel<Class<?>>> item) {
> final IModel<Class<?>> classModel =
> item.getModelObject();
> Check checkbox = new Check<Class<?>>("check",
> classModel);
> Label className = new Label("className",
> classModel.getObject().getSimpleName());
> item.add(checkbox, className);
> }
> };
> typesListview.setReuseItems(true);
> group.add(typesListview);
> form.add(group);
>
> Button saveButton = new Button("saveButton") {
> @Override
> public void onSubmit() {
> super.onSubmit();
> }
> };
> form.add(saveButton);
> add(form);
> }
>
> public List<Class<?>> getSearchableTypes() {
> List<Class<?>> searchableTypes = new ArrayList<Class<?>>();
>
> for (IModel<Class<?>> type : types) {
> searchableTypes.add(type.getObject());
> }
> return searchableTypes;
>
> }
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Saving-checked-choices-from-CheckGroup-tp4658408p4658411.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 checked choices from CheckGroup
Posted by Merlijn <lu...@gmail.com>.
Nope, added in the code. This is my code
public QuickSearchFilterPanel(String id) {
super(id);
Form form = new Form("filterform");
List<Class<?>> classes = resultItemHandlerPool.getTypes();
types = new ArrayList<IModel<Class<?>>>();
if (classes != null) {
for (final Class<?> clazz : classes) {
IModel<Class<?>> model = new IModel<Class<?>>() {
@Override
public Class<?> getObject() {
return clazz;
}
@Override
public void setObject(Class<?> object) {
}
@Override
public void detach() {
}
};
types.add(model);
}
}
group = new CheckGroup<IModel<Class<?>>>("checkboxgroup", new
PropertyModel<Collection<IModel<Class<?>>>>(this, "types"));
group.add(new CheckGroupSelector("checkall"));
ListView typesListview = new
ListView<IModel<Class<?>>>("typesList", new
PropertyModel<List<IModel<Class<?>>>>(this, "types")) {
@Override
protected void populateItem(final
ListItem<IModel<Class<?>>> item) {
final IModel<Class<?>> classModel =
item.getModelObject();
Check checkbox = new Check<Class<?>>("check",
classModel);
Label className = new Label("className",
classModel.getObject().getSimpleName());
item.add(checkbox, className);
}
};
typesListview.setReuseItems(true);
group.add(typesListview);
form.add(group);
Button saveButton = new Button("saveButton") {
@Override
public void onSubmit() {
super.onSubmit();
}
};
form.add(saveButton);
add(form);
}
public List<Class<?>> getSearchableTypes() {
List<Class<?>> searchableTypes = new ArrayList<Class<?>>();
for (IModel<Class<?>> type : types) {
searchableTypes.add(type.getObject());
}
return searchableTypes;
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Saving-checked-choices-from-CheckGroup-tp4658408p4658411.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 checked choices from CheckGroup
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
it sounds like you need listView.setReuseItems(true)
On Tue, Apr 30, 2013 at 12:45 PM, Merlijn <lu...@gmail.com> wrote:
> Hi everybody,
>
> I am making a filter for a searchfield where users can choose which items
> they want to choose. For this I am using a CheckGroup to show all the
> options. Now, whenever I choose an item and use the submit button, the
> other
> items get removed from the list. How can I make sure that the checked
> choices get remembered and the non-checked kept in the list?
>
> Kind regards,
>
> Merlijn
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Saving-checked-choices-from-CheckGroup-tp4658408.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
Wicket Training & Consulting
http://jWeekend.com <http://jweekend.com/>