1 package org.campware.cream.modules.screens; 2 3 42 43 import org.apache.torque.util.Criteria; 44 45 import org.apache.velocity.context.Context; 46 47 import org.campware.cream.om.Customer; 48 import org.campware.cream.om.CustomerPeer; 49 import org.campware.cream.om.LanguagePeer; 50 import org.campware.cream.om.CustomerCategoryPeer; 51 import org.campware.cream.om.HouseholdCategoryPeer; 52 import org.campware.cream.om.EducationCategoryPeer; 53 import org.campware.cream.om.CountryPeer; 54 import org.campware.cream.om.RegionPeer; 55 56 60 public class CustomerForm extends CreamForm 61 { 62 protected void initScreen() 63 { 64 setModuleType(ENTITY); 65 setModuleName("CUSTOMER"); 66 setIdName(CustomerPeer.CUSTOMER_ID); 67 setFormIdName("customerid"); 68 } 69 70 protected boolean getEntry(Criteria criteria, Context context) 71 { 72 try 73 { 74 Customer entry = (Customer) CustomerPeer.doSelect(criteria).get(0); 75 context.put("entry", entry); 76 return true; 77 } 78 catch (Exception e) 79 { 80 return false; 81 } 82 } 83 84 protected boolean getNew(Context context) 85 { 86 try 87 { 88 Customer entry = new Customer(); 89 context.put("entry", entry); 90 return true; 91 } 92 catch (Exception e) 93 { 94 return false; 95 } 96 } 97 98 protected boolean getLookups(Context context) 99 { 100 try 101 { 102 Criteria langcrit = new Criteria(); 103 langcrit.add(LanguagePeer.LANGUAGE_ID, 999, Criteria.GREATER_THAN); 104 langcrit.addAscendingOrderByColumn(LanguagePeer.LANGUAGE_NAME); 105 context.put("languages", LanguagePeer.doSelect(langcrit)); 106 107 Criteria custcatcrit = new Criteria(); 108 custcatcrit.add(CustomerCategoryPeer.CUSTOMER_CAT_ID, 999, Criteria.GREATER_THAN); 109 custcatcrit.addAscendingOrderByColumn(CustomerCategoryPeer.CUSTOMER_CAT_NAME); 110 context.put("customercats", CustomerCategoryPeer.doSelect(custcatcrit)); 111 112 Criteria countrycrit = new Criteria(); 113 countrycrit.add(CountryPeer.COUNTRY_ID, 999, Criteria.GREATER_THAN); 114 countrycrit.addAscendingOrderByColumn(CountryPeer.COUNTRY_NAME); 115 context.put("countries", CountryPeer.doSelect(countrycrit)); 116 117 Criteria regioncrit = new Criteria(); 118 regioncrit.add(RegionPeer.REGION_ID, 999, Criteria.GREATER_THAN); 119 regioncrit.addAscendingOrderByColumn(RegionPeer.REGION_NAME); 120 context.put("regions", RegionPeer.doSelect(regioncrit)); 121 122 Criteria incomecrit = new Criteria(); 123 incomecrit.add(HouseholdCategoryPeer.HOUSEHOLD_CAT_ID, 999, Criteria.GREATER_THAN); 124 incomecrit.addAscendingOrderByColumn(HouseholdCategoryPeer.HOUSEHOLD_CAT_NAME); 125 context.put("incomes", HouseholdCategoryPeer.doSelect(incomecrit)); 126 127 Criteria educrit = new Criteria(); 128 educrit.add(EducationCategoryPeer.EDUCATION_CAT_ID, 999, Criteria.GREATER_THAN); 129 educrit.addAscendingOrderByColumn(EducationCategoryPeer.EDUCATION_CAT_NAME); 130 context.put("educations", EducationCategoryPeer.doSelect(educrit)); 131 132 return true; 133 } 134 catch (Exception e) 135 { 136 return false; 137 } 138 } 139 140 } 141 | Popular Tags |