igor.vaynberg wrote:
> 
> class addressmodel extends ldm {
>  private final int idx;
>  private final imodel customer;
>  public addressmodel(imodel customer, address address) {
>    this.customer=customer;
>    this.idx=customer.getaddresses().indexof(address);
>   }
>   ...
> 

Nice. Thanks igor. 

Wouldn't you care about the performance of List.indexOf()? What about using
just the index as a parameter instead of the adress? That would imply a
different IDataProvider like this:

    public AdressDataProvider(IModel customerModel) {
        this.customerModel = customerModel;
    }

    public Iterator<?> iterator(final int first, final int count) {
        return new Iterator<Integer>() {
            private int i;

            public boolean hasNext() {
                return i < first + count;
            }

            public Integer next() {
                return i++;
            }

            public void remove() {

            }
        };
    }

    public IModel model(final Object object) {
        final Integer index = (Integer) object;
        return new AdressModel(customerModel, index);
    }

Although kind of weird, this way you would not have to determine the index
by calling indexOf().
What do you think?

By the way, is there a shorter way of getting an iterator over an Integer
range?

-- 
View this message in context: 
http://www.nabble.com/IDataProvider-LoadableDetachableModel-for-indexed-lists-tp21011916p21031001.html
Sent from the Wicket - User 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

Reply via email to