import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.mxchange.jcustomercore.model.customer.Customer;
import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
import org.mxchange.jshopcore.events.ShopCheckoutCompletedEvent;
import org.mxchange.jshopcore.model.basket.AddableBasketItem;
import org.mxchange.pizzaapplication.beans.basket.PizzaBasketWebSessionController;
import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController;
import org.mxchange.pizzaapplication.beans.customer.PizzaCustomerWebSessionController;
+import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestController;
import org.mxchange.pizzaapplication.beans.receipt.PizzaReceiptWebSessionController;
/**
@Inject
private PizzaBasketWebSessionController basketController;
+ /**
+ * Bean helper instance
+ */
+ @Inject
+ private PizzaWebRequestController beanHelper;
+
/**
* Event fired when a checkout was completed by the user
*/
@Inject
private PizzaContactWebSessionController contactController;
- /**
- * Customer instance
- */
- private Customer customer;
-
/**
* Customer bean
*/
// Construct container
WrapableCheckout wrapper = new CheckoutWrapper();
- wrapper.setCustomer(this.getCustomer());
+ wrapper.setCustomer(this.beanHelper.getCustomer());
wrapper.setList(list);
try {
}
// Fire event
- this.checkoutCompletedEvent.fire(new ShopCheckoutCompletedEvent(this.getCustomer()));
+ this.checkoutCompletedEvent.fire(new ShopCheckoutCompletedEvent(wrapper));
// All fine
return "checkout_done"; //NOI18N
}
- @Override
- public Customer getCustomer () {
- return this.customer;
- }
-
- @Override
- public void setCustomer (final Customer customer) {
- this.customer = customer;
- }
-
/**
* Initialization of this bean
*/
import java.io.Serializable;
import javax.ejb.Local;
-import org.mxchange.jcustomercore.model.customer.Customer;
/**
* An interface for the shop
*/
String doCheckout ();
- /**
- * Getter for customer instance
- * <p>
- * @return Customer instance
- */
- Customer getCustomer ();
-
- /**
- * Setter for customer instance
- * <p>
- * @param customer Customer instance
- */
- void setCustomer (final Customer customer);
-
}
private static final long serialVersionUID = 57_637_182_796_370L;
/**
- * Admin helper instance
+ * Bean helper instance
*/
@Inject
private PizzaWebRequestController beanHelper;
private AdminContactSessionBeanRemote adminContactBean;
/**
- * Admin helper instance
+ * Bean helper instance
*/
@Inject
private PizzaWebRequestController beanHelper;
private PizzaAdminCustomerSessionBeanRemote adminCustomerBean;
/**
- * Admin helper instance
+ * Bean helper instance
*/
@Inject
private PizzaWebRequestController adminHelper;
*/
package org.mxchange.pizzaapplication.beans.receipt;
-import java.text.MessageFormat;
import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
import javax.faces.FacesException;
+import javax.inject.Inject;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.mxchange.jcustomercore.model.customer.Customer;
-import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
import org.mxchange.jshopcore.model.receipt.ReceiptBeanRemote;
import org.mxchange.pizzaapplication.beans.BasePizzaController;
+import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestController;
/**
* Checkout controller
private static final long serialVersionUID = 95_723_834_783_478_781L;
/**
- * Customer instance
+ * Bean helper instance
*/
- private Customer customer;
+ @Inject
+ private PizzaWebRequestController beanHelper;
/**
* Remote bean instance
}
}
- @Override
- public void afterCheckoutCompleted (@Observes final ObservableCheckoutCompletedEvent event) {
- // Is all set?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null");
- } else if (event.getCustomer() == null) {
- // Throw NPE again
- throw new NullPointerException("event.customer is null");
- } else if (event.getCustomer().getCustomerId() == null) {
- // Throw NPE again ...
- throw new NullPointerException("event.customer.customerId is null");
- } else if (event.getCustomer().getCustomerId() < 0) {
- // Invalid id
- throw new IllegalArgumentException(MessageFormat.format("event.customer.customerId={0} is not valid.", event.getCustomer().getCustomerId()));
- }
-
- // Set customer
- this.setCustomer(event.getCustomer());
- }
-
@Override
public String fetchAccessKey () {
- return this.receiptBean.fetchAccessKey(this.getCustomer());
- }
-
- /**
- * Getter for customer instance
- * <p>
- * @return Customer instance
- */
- private Customer getCustomer () {
- return this.customer;
- }
-
- /**
- * Setter for customer instance
- * <p>
- * @param customer Customer instance
- */
- private void setCustomer (final Customer customer) {
- this.customer = customer;
+ return this.receiptBean.fetchAccessKey(this.beanHelper.getCustomer());
}
}
package org.mxchange.pizzaapplication.beans.receipt;
import java.io.Serializable;
-import org.mxchange.jshopcore.events.ObservableCheckoutCompletedEvent;
/**
* An interface for the shop
*/
public interface PizzaReceiptWebSessionController extends Serializable {
- /**
- * Observes events being fired when a checkout is completed by user
- * <p>
- * @param event Event being fired
- */
- void afterCheckoutCompleted (final ObservableCheckoutCompletedEvent event);
-
/**
* Fetches last access key for given customer instance
* <p>
private final AdminUserSessionBeanRemote adminUserBean;
/**
- * Admin helper instance
+ * Bean helper instance
*/
@Inject
private PizzaWebRequestController beanHelper;
<!-- @TODO Move this to i18n bundle //-->
Rechnung abrufen:
<h:link class="receipt_link" id="receipt" outcome="pdf" value="#{msg.LINK_OPEN_RECEIPT}" target="_blank">
- <f:param name="customer" value="#{checkoutController.customer.customerId}" />
+ <f:param name="customer" value="#{beanHelper.customer.customerId}" />
<f:param name="key" value="#{receiptController.fetchAccessKey()}" />
</h:link>
</ui:define>