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);
}
public object load() {
return customer.getobject().getaddresses().get(idx);
}
}
-igor
On Mon, Dec 15, 2008 at 3:04 AM, cretzel <[email protected]> wrote:
>
> Hi,
>
> what's the best way to implement an IDataProvider and a LoadableDetachable
> for an indexed list? Suppose I have a Customer who has a list of Adresses.
>
> class Customer {
> List<Adress> adresses;
> }
>
> Now I want to implement a data provider/ldm for the adresses of a customer.
> I suppose the usual way is an IDataProvider as an inner class which refers
> to the customer model of the component, like:
>
> class AdressDataProvider implements IDataProvider {
> public Iterator iterator() {
> Customer c = (Customer)Component.this.getModel(); // somehow get the
> customer model
> return c.getAdresses().iterator();
> }
>
> public IModel model(Object o) {
> Adress a = (Adress) o;
> // Return an LDM which loads the adress by id.
> return new AdressLoadableDetachableModel(a.getId());
> }
> }
>
> Question: How would I implement this, when the adress does not have an ID
> (e.g. it's a Hibernate Embeddable/CollectionOfElements) but can only be
> identified by its index in the customer.adresses list? How do I keep
> reference to the owning entity and the index?
>
> In fact, I know a solution, but I wonder if there's a common pattern to do
> this.
>
> --
> View this message in context:
> http://www.nabble.com/IDataProvider-LoadableDetachableModel-for-indexed-lists-tp21011916p21011916.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]