Discussion:
AjaxFallbackDefaultDataTable and CheckBox Column
dhongyt
2013-04-15 20:12:55 UTC
Permalink
I'm having a tough time understanding how I can get the objects selected.
Currently I have an AjaxFallbackDefaultDataTable with a Column of CheckBox.

I implemented a CheckBoxPanel so that I can add that to an AbstractColumn.
The AjaxFallbackDefaultDataTable is within a form and contains a form button
that I'm hoping to grab all the CheckBox checked.

I know that I need to put the functionality in the Form onSubmit section,
but having a tough time understanding how I can get the CheckBox checked.

CheckBoxPanel.java


CheckBoxPanel.html


Table.java


David



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-15 20:28:52 UTC
Permalink
Does your File object have a boolean property to store the selection in?

Then you have to bind your chechbox to the property:

public CheckboxPanel(String id, IModel<File> model)
{
super(id, model);
add(new CheckBox("check", new PropertyModel<Boolean>(model, "selected"));
}

In your #onSubmit() iterate over all files and filter out the selected ones.

Otherwise I'd recommend using a CheckGroup and Check components for each
row.
See wicket-examples' CheckGroupPage.java (no DataTable used though).

Regards
Sven
Post by dhongyt
I'm having a tough time understanding how I can get the objects selected.
Currently I have an AjaxFallbackDefaultDataTable with a Column of CheckBox.
I implemented a CheckBoxPanel so that I can add that to an AbstractColumn.
The AjaxFallbackDefaultDataTable is within a form and contains a form button
that I'm hoping to grab all the CheckBox checked.
I know that I need to put the functionality in the Form onSubmit section,
but having a tough time understanding how I can get the CheckBox checked.
CheckBoxPanel.java
CheckBoxPanel.html
Table.java
David
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-15 20:32:14 UTC
Permalink
If there are tons of files that might be listed, iterating through all those
files just to see which on is select could present a time issue correct?

Will CheckGroup and Check components solve this issue?

Is there a way to just grab checked files instead of iterating though and
seeing which one is checked?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658000.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-15 20:45:00 UTC
Permalink
Wicket iterates all files anyway for rendering, so iterating them once
again to find the selected ones will be no problem.

If you want to keep selection across paging on your DataTable, you
should definitely look into using CheckGroup/Check.

Sven
Post by dhongyt
If there are tons of files that might be listed, iterating through all those
files just to see which on is select could present a time issue correct?
Will CheckGroup and Check components solve this issue?
Is there a way to just grab checked files instead of iterating though and
seeing which one is checked?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658000.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-15 20:53:38 UTC
Permalink
Thanks Sven.

For the CheckGroup/Check which wicket-example are you talking about?
Are you talking about the ones on this page?
http://www.wicket-library.com/wicket-examples/index.html

If so then which example are you talking about on that page?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658002.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-16 07:55:50 UTC
Permalink
http://www.wicket-library.com/wicket-examples/compref/wicket/bookmarkable/org.apache.wicket.examples.compref.CheckGroupPage

It uses a ListView instead of a DataTable, but usage of CheckGroup/Check
is the same.

Hope this helps
Sven
Post by dhongyt
Thanks Sven.
For the CheckGroup/Check which wicket-example are you talking about?
Are you talking about the ones on this page?
http://www.wicket-library.com/wicket-examples/index.html
If so then which example are you talking about on that page?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658002.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-16 15:05:41 UTC
Permalink
Thanks again Sven.

I was able to implement the CheckGroup/Check functionality to the DataTable
but the results I am expecting isn't quite what I want. Not sure if its an
issue of implementation or if it supposed to work like that.

When I select the checkboxes on the first page, go to page 2, and return to
page 1 the checkboxes disappear.

When I select the checkboxes on the first page, submit my selection, go to
page 2 and return to page 1 the checkboxes are still there.

When I select the checkboxes on the first page, submit my selection, go to
page 2, select a checkbox and hit submit, selection from page one is gone,
but page 2 selection is there.

Is that how CheckGroup/Check supposed to work?
Since you describe that if you wanted the checks to persist on all pages I
assumed this is wrong?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658031.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-16 15:36:03 UTC
Permalink
Hi,

you'll have to add FormChoiceComponentUpdatingBehavior to your Check
components, so selection is sent to the server immediately.

Regards
Sven
Post by dhongyt
Thanks again Sven.
I was able to implement the CheckGroup/Check functionality to the DataTable
but the results I am expecting isn't quite what I want. Not sure if its an
issue of implementation or if it supposed to work like that.
When I select the checkboxes on the first page, go to page 2, and return to
page 1 the checkboxes disappear.
When I select the checkboxes on the first page, submit my selection, go to
page 2 and return to page 1 the checkboxes are still there.
When I select the checkboxes on the first page, submit my selection, go to
page 2, select a checkbox and hit submit, selection from page one is gone,
but page 2 selection is there.
Is that how CheckGroup/Check supposed to work?
Since you describe that if you wanted the checks to persist on all pages I
assumed this is wrong?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658031.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-16 17:01:09 UTC
Permalink
I have added this to my check


But now I get the error "Behavior can only be added to an instance of a
FormComponent"

I was looking at the javadoc and seems to me that Check is not a
FormComponent, do you mean for me to add this behavior to the CheckGroup?
But adding it to the CheckGroup doesn't make much sense to me.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658040.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-16 17:32:34 UTC
Permalink
Looks like it does save. I created an AjaxFormChoiceComponentBehavior on my
CheckGroup.

When I do the check on page one, go to page 2, and return the checks are
still there.
When I do the check on page one, go to page 2, and check off items in page
2, and return to page one check on page one are gone.



I think I am beginning to understand my problem.
Is it because when I do a


The group is only added to the first 50 items that show up, so if I want it
to work with the rest of the pages, does that mean that I also have to
implement the AjaxPagingNavigationBehavior?

Or am I just missing something on the onUpdate function?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658042.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-16 18:31:17 UTC
Permalink
Sorry, you're right, you have to add the behavior to the CheckGroup.

And you're right too that the CheckGroup will lose its selection from a
previous paging.
I'm afraid you'll have to implement your own solution with ChekBoxes and
an AjaxFormComponentBehavior, managing the selected items in your own
collection.

Sven
Post by dhongyt
Looks like it does save. I created an AjaxFormChoiceComponentBehavior on my
CheckGroup.
When I do the check on page one, go to page 2, and return the checks are
still there.
When I do the check on page one, go to page 2, and check off items in page
2, and return to page one check on page one are gone.
I think I am beginning to understand my problem.
Is it because when I do a
The group is only added to the first 50 items that show up, so if I want it
to work with the rest of the pages, does that mean that I also have to
implement the AjaxPagingNavigationBehavior?
Or am I just missing something on the onUpdate function?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658042.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-16 18:37:09 UTC
Permalink
Could you please explain the reason why we lose the CheckGroup from the
previous paging?

Is it because the CheckGroup is set on the first 50 and when going to the
next 50 it creates a new CheckGroup therefore losing the first CheckGroup?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658046.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-16 20:38:24 UTC
Permalink
Hi,

on each click, AjaxFormChoiceUpdatingBehavior sends *all* checked
checkboxes to the server, overwriting the previously selected with the
now selected ones.
For a paging DataTable only those checkboxes from the current paging are
visible, thus the selection from the previous paging is lost.

Hope this helps
Sven
Post by dhongyt
Could you please explain the reason why we lose the CheckGroup from the
previous paging?
Is it because the CheckGroup is set on the first 50 and when going to the
next 50 it creates a new CheckGroup therefore losing the first CheckGroup?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658046.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-17 18:35:17 UTC
Permalink
So if I would like to store the checks on many different pages, then I would
have to override the AjaxPagingNavigationBehavior function? And in that
function when the page changes save the current CheckBox ArrayList into some
sort of HashMap maybe? And load the page of checks depending on the page?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658061.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-17 19:32:23 UTC
Permalink
Either you have a AjaxFormComponentUpdatingBehavior on each Checkbox, so
a selection is automatically synced to the server.

Or you make the paging submit a containing form:

http://apache-wicket.1842946.n4.nabble.com/Wicket-user-Editable-DataTable-with-Paging-td1925442.html

Regards
Sven
Post by dhongyt
So if I would like to store the checks on many different pages, then I would
have to override the AjaxPagingNavigationBehavior function? And in that
function when the page changes save the current CheckBox ArrayList into some
sort of HashMap maybe? And load the page of checks depending on the page?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658061.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-18 21:12:09 UTC
Permalink
So I'm trying to override the PagingNavigator by creating my own custom
navigator.





My issue is that for some reason I can't seem to put the page numbers on
pageNumber.
My error is:
Unable to find component with id 'navigation' in [Form [Component id =
linkForm]]

Not quite sure what navigation is supposed to be.

Am I going about this correctly?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658099.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-18 22:03:57 UTC
Permalink
I think I wrapped my head on it a bit more and starting to understand what
navigation is.
So now I have this.


I believe I need to override the PagingNavigator populateItem function but
I'm trying to get a regular population working but now I have this error:

Last cause: Close tag not found for tag: . For PagingNavigator Components
only raw markup is allow in between the tags but not other Wicket Component.
Component: [PagingNavigator [Component id = navigation]]



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658100.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-19 09:17:03 UTC
Permalink
Check SubmitLinkPagingNavigator's markup.

Sven
Post by dhongyt
I think I wrapped my head on it a bit more and starting to understand what
navigation is.
So now I have this.
I believe I need to override the PagingNavigator populateItem function but
Last cause: Close tag not found for tag: . For PagingNavigator Components
only raw markup is allow in between the tags but not other Wicket Component.
Component: [PagingNavigator [Component id = navigation]]
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658100.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-19 13:48:39 UTC
Permalink
This is the markup that I have. The span "navigation" closing tag is
obviously there. Am I missing something?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658118.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-19 14:09:58 UTC
Permalink
I noticed that I was using PagingNavigator instead of the PagingNavigation.

Changed my code over to use PagingNavigation results in:
Last cause: The component(s) below failed to render. Possible reasons could
be that: 1) you have added a component in code but forgot to reference it in
the markup (thus the component will never be rendered), 2) if your
components were added in a parent container then make sure the markup for
the child container includes them in <wicket:extend>.

1. [PagingNavigation [Component id = navigation]]
2. [LoopItem [Component id = 0]]
3. [PagingNavigationLink [Component id = pageLink]]
4. [Component id = pageNumber]
5. [LoopItem [Component id = 1]]
6. [PagingNavigationLink [Component id = pageLink]]
7. [Component id = pageNumber]
8. [LoopItem [Component id = 2]]
9. [PagingNavigationLink [Component id = pageLink]]
10. [Component id = pageNumber]
11. [LoopItem [Component id = 3]]
12. [PagingNavigationLink [Component id = pageLink]]
13. [Component id = pageNumber]
14. [LoopItem [Component id = 4]]
15. [PagingNavigationLink [Component id = pageLink]]
16. [Component id = pageNumber]
17. [LoopItem [Component id = 5]]
18. [PagingNavigationLink [Component id = pageLink]]
19. [Component id = pageNumber]
20. [LoopItem [Component id = 6]]
21. [PagingNavigationLink [Component id = pageLink]]
22. [Component id = pageNumber]
23. [LoopItem [Component id = 7]]
24. [PagingNavigationLink [Component id = pageLink]]
25. [Component id = pageNumber]
26. [LoopItem [Component id = 8]]
27. [PagingNavigationLink [Component id = pageLink]]
28. [Component id = pageNumber]
29. [LoopItem [Component id = 9]]
30. [PagingNavigationLink [Component id = pageLink]]
31. [Component id = pageNumber]
32. [PagingNavigationLink [Component id = first]]
33. [PagingNavigationIncrementLink [Component id = prev]]
34. [PagingNavigationIncrementLink [Component id = next]]
35. [PagingNavigationLink [Component id = last]]



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658119.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-19 17:34:40 UTC
Permalink
I have been playing some more with the code and I'm now thinking that maybe I
should just overrite the newNavigation function.

That will allow me to override the newPagingNavigationLink function.

My troubles are that if I want to return a SubmitLink here, where would my
form tags be in the mark up? And where should I create the form component?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658129.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-19 19:34:26 UTC
Permalink
Easiest is to wrap the whole table in a form.

Sven
Post by dhongyt
I have been playing some more with the code and I'm now thinking that maybe I
should just overrite the newNavigation function.
That will allow me to override the newPagingNavigationLink function.
My troubles are that if I want to return a SubmitLink here, where would my
form tags be in the mark up? And where should I create the form component?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658129.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
dhongyt
2013-04-19 19:52:46 UTC
Permalink
Right which is what I have but I'm having a tough time understanding how I
need to override the navigator.



I have done it many ways and none of them seem to work.

I think I'm supposed to override this


But SubmitLink wants the form to be in its constructor for it to work
correctly right?
And how to I make it update the DataView to go to the next page?



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658133.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Sven Meier
2013-04-20 06:04:48 UTC
Permalink
Hi,

the classes in the following archive duplicate AjaxNavigationToolbar but
use AjaxFormSubmitBehaviors instead:

https://dl.dropboxusercontent.com/u/52076310/AjaxSubmitPaging.zip

Usage:

Form form = new Form("form");
add(form);

form.add(new AjaxSubmitDefaultDataTable<Foo, String>("table",
columns, dataProvider, 8));

Hope this helps
Sven
Post by dhongyt
Right which is what I have but I'm having a tough time understanding how I
need to override the navigator.
I have done it many ways and none of them seem to work.
I think I'm supposed to override this
But SubmitLink wants the form to be in its constructor for it to work
correctly right?
And how to I make it update the DataView to go to the next page?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackDefaultDataTable-and-CheckBox-Column-tp4657998p4658133.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org

Loading...