View Javadoc

1   package org.paneris.bibliomania;
2   
3   import org.melati.Melati;
4   import org.melati.servlet.Form;
5   import org.melati.poem.BaseFieldAttributes;
6   import org.melati.poem.Field;
7   import org.melati.poem.FieldAttributes;
8   import org.webmacro.servlet.WebContext;
9   
10  public class DeliveryCharges extends BibliomaniaServlet {
11  
12    /**
13     * 
14     */
15    private static final long serialVersionUID = 1L;
16  
17    protected String bibliomaniaHandle(Melati melati, WebContext context)
18              throws Exception {
19          
20      BibliomaniaDatabase db = (BibliomaniaDatabase) melati.getDatabase();
21      db.setupContext(melati, context, null, null);
22      String localeString = 
23                   Form.getFieldNulled(melati.getServletTemplateContext(),"locale");
24      Integer countryCodeId = 
25           Form.getIntegerField(melati.getServletTemplateContext(),"field_country");
26      context.put("countries", new Field(countryCodeId, 
27                  new BaseFieldAttributes(
28              (FieldAttributes)db.getShopOrderTable().getCountryColumn(),  true)));
29      if (countryCodeId != null) {
30        Country country = (Country)db.getCountryTable().getIdColumn().firstWhereEq(countryCodeId);
31        context.put("country", country);
32        DeliveryChargeBand band = country.getDeliverycharge();
33        context.put("charges", db.getDeliveryChargeTable().getBandColumn().selectionWhereEq(band.getTroid()));
34      }
35      context.put("currency", db.getCurrencyTable().getCurrency(localeString));
36      context.put("locale", localeString);
37      return "DeliveryCharges.wm";
38    }
39  }