You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mlabs <ml...@gmail.com> on 2012/03/09 01:56:37 UTC

proper way to refresh a DataTable?

I'm trying to refresh the model of a DataTable when the user clicks an ajax
link on my page...
I pass an instance of SortableDataProvider<foo> to the table....
In the onClick() handler of the ajax link I call detach() on it ... hoping
that this will trigger a rebuild..but it doesn't ... the iterator() code
never gets hit again...
Here is my dataprovider.. some code omitted for clarity..

public class SortableFooDataProvider extends SortableDataProvider<Foo>{
  private List<Foo> mRows;
  public SortableFooDataProvider(){..}
  
  @Override
  public Iterator(int i, int j){
    if (mRows==null)
      mRows = new ArrayList<Foo>();

    // fill mRows with rows.....

    return mRows.iterator();
  }

  @Override
  public int size(){
    return (mRows!=null)?mRows.size():0;
  }

  @Override
  public IModel<Foo> model(Foo f) {return new Model(f);}

  @Override
  public void detach(){
    mRows = null;
    super.detach();
  }
}

any ideas what I'm doing wrong?

TIA




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/proper-way-to-refresh-a-DataTable-tp4458199p4458199.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: proper way to refresh a DataTable?

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi,

Have you added the datatable to the AjaxRequestTarget of the link's 
onClick method? That should do it.

On 08/03/2012 7:56 PM, mlabs wrote:
> I'm trying to refresh the model of a DataTable when the user clicks an ajax
> link on my page...
> I pass an instance of SortableDataProvider<foo>  to the table....
> In the onClick() handler of the ajax link I call detach() on it ... hoping
> that this will trigger a rebuild..but it doesn't ... the iterator() code
> never gets hit again...
> Here is my dataprovider.. some code omitted for clarity..
>
> public class SortableFooDataProvider extends SortableDataProvider<Foo>{
>    private List<Foo>  mRows;
>    public SortableFooDataProvider(){..}
>
>    @Override
>    public Iterator(int i, int j){
>      if (mRows==null)
>        mRows = new ArrayList<Foo>();
>
>      // fill mRows with rows.....
>
>      return mRows.iterator();
>    }
>
>    @Override
>    public int size(){
>      return (mRows!=null)?mRows.size():0;
>    }
>
>    @Override
>    public IModel<Foo>  model(Foo f) {return new Model(f);}
>
>    @Override
>    public void detach(){
>      mRows = null;
>      super.detach();
>    }
> }
>
> any ideas what I'm doing wrong?
>
> TIA
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/proper-way-to-refresh-a-DataTable-tp4458199p4458199.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
>

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