protected void createComponents()
{
Form form = new Form("form");
final XRaceSession session = getXRaceSession();
final Cart cart = session.getCart();
form.add(new CartConfirmationListView("cartConfirmationListView"));
form.add(new CurrencyLabel("total", new PropertyModel(cart, "total")));
form.add(new CurrencyLabel("sousTotal", new PropertyModel(cart,
"sousTotal")));
form.add(new CurrencyLabel("escompte", new PropertyModel(cart,
"escompte")));
form.add(new CheckBox("acceptedConditions", new PropertyModel(this,
"acceptedConditions")));
form.add(new TextArea("conditions", new Model(ResourceBundle.getBundle(
"org/xrace/XRaceApplication").getString("Global.conditions"))));
form.add((new Label("policyTitle", new ResourceModel(
"Global.policyTitle"))));
form.add((new MultiLineLabel("policy", new ResourceModel(
"Global.policy"))));
form.add(new Button("pay", new ResourceModel("pay"))
{
private static final long serialVersionUID = 3534043602619164257L;
@Override
public void onSubmit()
{
if (cart.getItems().size() < 1)
{
error(getLocalizer().getString("emptyCartError", this));
}
else if (!acceptedConditions)
{
error(getLocalizer().getString("mustAcceptConditionsError",
this));
}
else
{
// Création de la facture avec les items du panier d'achats
final Facture facture = factureService.createFacture(
session.getPersonne(), session.getCart());
session.getCart().clear();
final Transaction transaction = transactionService
.createTransaction(session.getPersonne(), facture);
final String link = desjardins3Service.runTrx(transaction);
final RedirectPage url = new RedirectPage(link);
this.setResponsePage(url);
}