Hi!
Im using the Seam framework (With EntityQuery and EntityHome)
Im doing a form for a Sale Order request, with order, details and products...
One Order have a lot of details, but a detail only have a Order
One Product have a lot of details, but a detail only have a Product
On the same page, i want to save:
- One Order
- One Product
- One Detail and get related with the Order and the product
I have some trouble with the instance, with a submit i do a method (saveOrder), i do 2 persist on my session bean, and later i have to redirect to the same page but i need that only one instance stays (Order)... the other have to get destroy (Detail and Product)... because the same page have to be ready to save a new detail
The method that im using is this:
public void saveOrder() {
orderHome.saveNew(); // it do the Order Persist
this.wire();
this.persist(); // It do the Detail Persist
Details details= this.getDefinedInstance();
this.total = Float.valueOf( "0" );
if (details != null) {
if(details.getQuantity() == null){
details.setQuantity(Float.valueOf( "1" ));
this.update();
}
Products products = productsHome.getDefinedInstance();
if (products != null) {
this.total = products.getPricesale() * detallesfacturas.getQuantity();
}
}
}