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.
Any tips?
Thank you.
Gabriel Malimpensa.
Sao Carlos, Sao Paulo, Brazil.
Gabriel Malimpensa 's gravatar image asked Nov 1 2014 at 12:26 in Isis-Users by Gabriel Malimpensa

4 Answers

Hi,
Are you aware of DomainObjectContainer ?
See http://isis.apache.org/reference/DomainObjectContainer.html and all
links in "Object management" section at
http://isis.apache.org/documentation.html
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
Martin Grigorov 's gravatar image answered Nov 1 2014 at 13:18 by Martin Grigorov
Yes, I am aware of this.
My doubt is how to create a form to persist an entity like the others, but
I need to persist such entity with a list of items.
My example is: an entity Purchase and many entities PurchaseItem. I need
that Isis renders a list or a table, something like this.
I don't know if I explained correctly. I hope so.
Sorry for my english.
Gabriel Malimpensa.
Sao Carlos, Sao Paulo, Brazil.
2014-11-01 18:18 GMT-02:00 Martin Grigorov
Gabriel Malimpensa 's gravatar image answered Nov 1 2014 at 13:59 by Gabriel Malimpensa
See ToDoItems class in the Todo app demo.
It is a domain service and a repository for ToDoItem objects.
I think you need a Purchase repository for PurchaseItem objects.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
Martin Grigorov 's gravatar image answered Nov 1 2014 at 14:12 by Martin Grigorov
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
Dan Haywood 's gravatar image answered Nov 3 2014 at 00:23 by Dan Haywood