Thanks Igor!
I changed all the classes under wicket.markup.html.navigation.paging
to use SubmitLink instead of Link to begin with, adjusted my CheckBox
model according to your suggestion with some modifications. And bingo!
it seems to be working fine. But seriously this looks like magic and
i'm not sure if it really works !! :)
On 1/11/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> everything is so complicated...and why?
> have a list of ids or whatever the checkbox represents in your page and use
> submit links.
>
> here is a simple model for the checkbox that will push proper items into the
> list, currently i use it with ajax, but i think it will work with submit
> links just fine.
>
> remember, the force is in the model :) assignments is a list that is a
> property of the page. hope this helps.
>
> -Igor
>
>
> private class CheckBoxModel implements IModel {
> // id the model represents
> private final long groupId;
>
> public CheckBoxModel(long groupId) {
> this.groupId=groupId;
> }
>
> public IModel getNestedModel() {
> return null;
> }
>
> public Object getObject(Component component) {
> Collection<Long> groups= assignments.get(getSelectedUserId());
> if (groups!=null&&groups.contains(groupId)) {
> return (Boolean)true;
> }
> return (Boolean)false;
> }
>
> @SuppressWarnings("unchecked")
> public void setObject(Component component, Object object) {
> boolean value=(Boolean)object;
> boolean selected=(Boolean) getObject(component);
>
> if (value) {
> if (!selected) {
> Collection c= assignments.get(getSelectedUserId());
> if (c==null) {
> c=new ArrayList();
> }
> c.add(groupId);
> assignments.put (getSelectedUserId(), c);
> }
> } else {
> if (selected) {
> assignments.get(getSelectedUserId()).remove(groupId);
> }
> }
> }
>
> public void detach() {
> }
>
> }
>
>
>
> -Igor
>
>
>
>
> On 1/11/06, Laurent PETIT < [EMAIL PROTECTED] > wrote:
> > Yes, you're on your own for this use case : you need to manage a
> > presentation model that encapsulate your "pure" domain model.
> >
> > Or, you could try to subclass the DataView in order to not remove()
> > the elements but instead just play with their visibility.
> >
> > But I'm not sure it's that easy to do, and also it will depend on the
> > size of the list your displaying, since this will imply to keep a lot
> > of components in session ...
> > On 1/11/06, Johan Compagner <[EMAIL PROTECTED]> wrote:
> > > ahh ok
> > > then you need 1.2
> > > so that you can use SubmiLinks in a page navigator (you need youre own
> > > then)
> > >
> > > Because when you go from one page to another you need to submit the form.
> > > So
> > > you can't use regular links but you have to submit the form
> > > the checkboxes are on and then go on.
> > >
> > > But this can be a tricky situation because you have a list that builds up
> > > the components everytime you render it.
> > > So you can't store the state in the component itself you have to push it
> > > to
> > > a model when a paging link is clicked.
> > >
> > >
> > > johan
> > >
> > >
> > >
> > > On 1/11/06, karthik Guru < [EMAIL PROTECTED]> wrote:
> > > >
> > > > The html shows this link..for page navigator. So its not a form submit
> > > > and
> > > hence the model will not get updated when navigating?
> > > >
> > > > <a
> > > href="/WicketWorld/app?path=0:navigator:navigation:0:pageLink&version=3&interface=ILinkListener"
> > > wicket:id="pageLink">
> > > > <span wicket:id="pageNumber">1</span>
> > > > </a>
> > > >
> > > > page1-> select checkbox ->navigate to page2 through page navigator ->
> > > navigate to page1 again (Now checkbox selection state in page1 is lost
> > > since
> > > the model for checkbox never got updated when moving to page2) ?
> > > >
> > > > Is my understanding wrong?
> > > >
> > > >
> > > > On 1/11/06, karthik Guru < [EMAIL PROTECTED] > wrote:
> > > > >
> > > > > Looks like am missing something. I'm holding on to the state in a
> > > > > model
> > > and DataView reads that state when displaying for the first time. But does
> > > wicket update that when navigating across pages? Because I dont see that
> > > happening.
> > > > >
> > > > > For eg ,
> > > > >
> > > > >
> > > > > << <1 2 3> >>
> > > > > [id] [name] [select]
> > > > > 1 hello1 checkbox
> > > > >
> > > > > 2 hello2 checkbox
> > > > >
> > > > > 3 hello3 checkbox
> > > > >
> > > > > If user selects the checkbox corresponding to [id] 1, and then moves
> > > > > to
> > > page '2' and comes back to '1', the selection is lost.
> > > > > Please do let me know if am missing something really basic here. I'm
> > > using DataView with PagingNavigator.
> > > > >
> > > > >
> > > > >
> > > > > On 1/11/06, Johan Compagner < [EMAIL PROTECTED] > wrote:
> > > > > > You should hold on to the data in a model.
> > > > > >
> > > > > > johan
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 1/11/06, karthik Guru <[EMAIL PROTECTED] > wrote:
> > > > > > >
> > > > > > > One of the columns in my table (DataView) is a checkbox. I have
> > > paging enabled through PagingNavigator and it works fine. I had a question
> > > on retaining the checkbox state when paging. Right now if user checks a
> > > checkbox and navigates to other pages using the paging navigator, by the
> > > time he comes back to the first page, his selection is lost.
> > > > > > > Does the underlying model get updated when paging? It looks like a
> > > link and i doubt if it gets updated. Does it come down to how to submit a
> > > html page when a link is clicked? How do i retain the checkbox state while
> > > the user is navigating?
> > > > > > >
> > > > > > > thank you,
> > > > > > > karthik
> > > > > > >
> > > > > > > << <1 2 3> >>
> > > > > > > [id] [name] [select]
> > > > > > > 1 hello1 checkbox
> > > > > > >
> > > > > > > 2 hello2 checkbox
> > > > > > >
> > > > > > > 3 hello3 checkbox
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> > for problems? Stop! Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> > http://ads.osdn.com/?ad_idv37&alloc_id865&opclick
> > _______________________________________________
> > Wicket-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
>
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user