On 1 November 2014 19:26, Gabriel Malimpensa <[email protected]> wrote:

> Good afternoon.
>
> I am trying to create a domain service with a method to finish a purchase.
> So, I have to set in the purchase a list of items, and I don't know how I
> do this.
> I imagine the interface with a field to find items and a table or a list
> showing the selected items by the user.
>
>
It sounds like you want to obtain a reference to an existing domain object
(probably "Product" from your description) so that your new "Purchase" (or
"Order") object references it...

public class Order {

    private Product product;  // I'm guessing this is what needs to be set
up.
    private int quantity;
    /// other fields
    /// getters and setters omitted

}

So you could use an action to create, with an autoComplete supporting
method [1] for the appropriate action parameter , eg:

public class Orders {   // the domain service

    public Order createOrder(Product p, @Named("Quantity") int quantity) {
        Order o = container.newTransientInstance(Order.class);
        o.setProduct(p);
        o.setQuantity(quantity);
        container.persist(p);
    }
    public Collection<Product> autoComplete0CreateOrder(String
productRefOrDescription) {
        return products.findByRefOrDescription(productRefOrDescription);
    }

    @Inject private DomainObjectContainer container;
    @Inject private Products products;
}

where Products is a repository for the Product class letting you locate
products by their reference or description.

HTH
Dan


[1]
http://isis.apache.org/how-tos/how-to-03-025-How-to-specify-an-autocomplete-for-an-action-parameter.html






> Any tips?
>
> Thank you.
> Gabriel Malimpensa.
> Sao Carlos, Sao Paulo, Brazil.
>

Reply via email to