Inmethod Grid Select All or Reload Grid

2011-04-17 Thread GJT
Hi there

I started using the Inmethod DataGrid because I need resizable tables and I
need to be able to select multi entries.

First, I had the problem that I couldn't select all entries and the multi
select didin't work properly. In this forum I found out that I have to
implement hashCode in the model. After that it worked, but the grid didn't
refresh anymore after I had changed the model. 

To sum up, if I use the hashCode, I the table doesn't refresh after I change
the model. If I don't use hashCode, the selection doesn't work properly.

The code for hashCode() and equals I'm using:

  public int hashCode() {
 return new Long(id).hashCode();
  }

  public boolean equals(final Object obj) {
 if (obj == this) {
return true;
 } else if (obj == null) {
return false;
 } else if (obj instanceof DetachableModel) {
DetachableModel other = (DetachableModel) obj;
return other.id == this.id;
 }
 return false;
  }

Thanks for your help.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3456685.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread Attila Király
2011/4/18 GJT 

> Hi there
>
> I started using the Inmethod DataGrid because I need resizable tables and I
> need to be able to select multi entries.
>
> First, I had the problem that I couldn't select all entries and the multi
> select didin't work properly. In this forum I found out that I have to
> implement hashCode in the model. After that it worked, but the grid didn't
> refresh anymore after I had changed the model.
>
> To sum up, if I use the hashCode, I the table doesn't refresh after I
> change
> the model. If I don't use hashCode, the selection doesn't work properly.
>
> The code for hashCode() and equals I'm using:
>
>  public int hashCode() {
> return new Long(id).hashCode();
>  }
>
>  public boolean equals(final Object obj) {
> if (obj == this) {
>return true;
> } else if (obj == null) {
>return false;
> } else if (obj instanceof DetachableModel) {
>DetachableModel other = (DetachableModel) obj;
>return other.id == this.id;
> }
> return false;
>      }
>
> Thanks for your help.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3456685.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>
Hi

Which version are you using (1.4 or 1.5)? What do you mean the grid does not
refresh?

I suggest
examining inmethod-grid-examples (com.inmethod.grid.examples.pages.datagrid
package) which seems to work fine.

Attila


Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread GJT
I am using wicket 1.4.16 and inmethod-grid 1.4.17

For example, I have a list of flights. I select every flight I want to
change. So I press a button which opens a modal window. There I change the
times of the selected flights. After saving, the table should load the new
data (target.addComponent(grid)). That's what I mean with refresh. 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3456877.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread Marc Nuri San Félix
Try this:
+++
grid.markAllItemsDirty();
grid.update(); // <- This adds the grid to AjaxRequestTarget,
so target.addComponent(grid) is not necessary
+++
Regards
--
Marc Nuri

On Mon, Apr 18, 2011 at 10:15, GJT  wrote:

> I am using wicket 1.4.16 and inmethod-grid 1.4.17
>
> For example, I have a list of flights. I select every flight I want to
> change. So I press a button which opens a modal window. There I change the
> times of the selected flights. After saving, the table should load the new
> data (target.addComponent(grid)). That's what I mean with refresh.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3456877.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread GJT
I tried that before and I tried it again, but it doesn't work. I think the
problem is somewhere with my LoadableDetachableModel which contains a
constructor, equals(Object), hashCode() and load()


Marc Nuri wrote:
> 
> Try this:
> +++
> grid.markAllItemsDirty();
> grid.update(); // <- This adds the grid to AjaxRequestTarget,
> so target.addComponent(grid) is not necessary
> +++
> Regards
> --
> Marc Nuri
> 
> On Mon, Apr 18, 2011 at 10:15, GJT <taulant.gju...@helvetic.com>
> wrote:
> 
>> I am using wicket 1.4.16 and inmethod-grid 1.4.17
>>
>> For example, I have a list of flights. I select every flight I want to
>> change. So I press a button which opens a modal window. There I change
>> the
>> times of the selected flights. After saving, the table should load the
>> new
>> data (target.addComponent(grid)). That's what I mean with refresh.
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3456877.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
> 


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3457237.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread Marc Nuri San Félix
Have you debugged your project to see if the IDatasource is queried when you
perform the Ajax reload??
If you reload the page does the data update??
--
Marc Nuri

On Mon, Apr 18, 2011 at 13:19, GJT  wrote:

> I tried that before and I tried it again, but it doesn't work. I think the
> problem is somewhere with my LoadableDetachableModel which contains a
> constructor, equals(Object), hashCode() and load()
>
>
> Marc Nuri wrote:
> >
> > Try this:
> > +++
> > grid.markAllItemsDirty();
> > grid.update(); // <- This adds the grid to AjaxRequestTarget,
> > so target.addComponent(grid) is not necessary
> > +++
> > Regards
> > --
> > Marc Nuri
> >
> > On Mon, Apr 18, 2011 at 10:15, GJT <taulant.gju...@helvetic.com>
> > wrote:
> >
> >> I am using wicket 1.4.16 and inmethod-grid 1.4.17
> >>
> >> For example, I have a list of flights. I select every flight I want to
> >> change. So I press a button which opens a modal window. There I change
> >> the
> >> times of the selected flights. After saving, the table should load the
> >> new
> >> data (target.addComponent(grid)). That's what I mean with refresh.
> >>
> >> --
> >> View this message in context:
> >>
> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3456877.html
> >> Sent from the Users forum mailing list archive at Nabble.com.
> >>
> >> -------------
> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >> For additional commands, e-mail: users-h...@wicket.apache.org
> >>
> >>
> >
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3457237.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread GJT
After debugging, I found out the with the hashCode method, the columns don't
load. If I take out the hashCode method, the columns loads the data again.
But as I said, the selection doesn't work anymore. 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3457355.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread Marc Nuri San Félix
For what you're saying, I believe you've got something messed up in your
Bean's hashCode and equals method.
Inmethod's Datagrid keeps a Set (HashSet) of IModel objects to keep track of
which items are selected. If you've implemented correctly the equals method
in your bean and believe that there's something wrong in the way the
Datagrid keeps track of selected items, you can implement your
own isItemSelected, resetSelectedItems, selectAllVisibleItems methods in a
custom implementation of Datagrid or Abstractdatagrid.
--
Marc Nuri

On Mon, Apr 18, 2011 at 14:19, GJT  wrote:

> After debugging, I found out the with the hashCode method, the columns
> don't
> load. If I take out the hashCode method, the columns loads the data again.
> But as I said, the selection doesn't work anymore.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3457355.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Inmethod Grid Select All or Reload Grid

2011-04-18 Thread Attila Király
Can you provide a minimal example webapp showing the problem?

Attila

2011/4/18 GJT 

> After debugging, I found out the with the hashCode method, the columns
> don't
> load. If I take out the hashCode method, the columns loads the data again.
> But as I said, the selection doesn't work anymore.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-Reload-Grid-tp3456685p3457355.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


RE: Inmethod Grid Select All or Reload Grid

2011-04-20 Thread Chris Colman
I tried this exact thing today and had the same results.. no update

grid.markAllItemsDirty();
grid.update();

I have a feeling that the equals method has to return false when objects are 
updated to force a redisplay. For this reason I'm guessing that the equality 
should not be solely based on the object's database id because that doesn't 
change when the object is updated. 

Perhaps we could include the object's version number in the equality test as 
well, which will change when the object is updated (version is automatically 
managed by our ORM but probably same across most ORMs).

In our case we use JDO so I'm guessing if we add an extra comparison to the 
equals method we might get the update working as expected eg.,


boolean 
equals(Object obj)
{
   

   if ( !JDOHelper.getVersion(this).equals(JDOHelper.getVersion(obj) )
 return false;

   
}


Hmmm, I'll try that first thing tomorrow morning when I hit the office.

>-Original Message-
>From: Attila Király [mailto:kiralyattila...@gmail.com]
>Sent: Tuesday, 19 April 2011 3:26 AM
>To: users@wicket.apache.org
>Subject: Re: Inmethod Grid Select All or Reload Grid
>
>Can you provide a minimal example webapp showing the problem?
>
>Attila
>
>2011/4/18 GJT 
>
>> After debugging, I found out the with the hashCode method, the columns
>> don't
>> load. If I take out the hashCode method, the columns loads the data
>again.
>> But as I said, the selection doesn't work anymore.
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Inmethod-Grid-Select-All-or-
>Reload-Grid-tp3456685p3457355.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>

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



Re: Inmethod Grid Select All or Reload Grid

2011-04-20 Thread Marc Nuri San Félix
Hello.
Of course, objects updated in the database shouldn't be equal to those
previously displayed in the table (they aren't equal). If you don't comply
to this you'll have problems not only with inmehtod grid.
The equals method of my beans always include at least this:

if (this.id != other.id && (this.id == null || !this.id.equals(
other.id))) {
return false;
}
if (this.version!= other.version&& (this.version== null ||
!this.version.
equals(other.version))) {
return false;
}
+++
The above may also be the problem when dealing with the selection, because
an object previously selected that has been updated in the database, won't
be selected again (it won't equals the previous version). That is why you
should implement your own selection methods in the DataGrid if you're
dealing with objects from a database.
Regards
On Wed, Apr 20, 2011 at 15:42, Chris Colman wrote:

> I tried this exact thing today and had the same results.. no update
>
> grid.markAllItemsDirty();
> grid.update();
>
> I have a feeling that the equals method has to return false when objects
> are updated to force a redisplay. For this reason I'm guessing that the
> equality should not be solely based on the object's database id because that
> doesn't change when the object is updated.
>
> Perhaps we could include the object's version number in the equality test
> as well, which will change when the object is updated (version is
> automatically managed by our ORM but probably same across most ORMs).
>
> In our case we use JDO so I'm guessing if we add an extra comparison to the
> equals method we might get the update working as expected eg.,
>
>
> boolean
> equals(Object obj)
> {
>   
>
>   if ( !JDOHelper.getVersion(this).equals(JDOHelper.getVersion(obj) )
> return false;
>
>   
> }
>
>
> Hmmm, I'll try that first thing tomorrow morning when I hit the office.
>
>