Пример #1
0
 public Object edit(Customer customer) {
   this.customer = customer;
   this.contacts = new ArrayList<Contact>(Arrays.asList(customer.getContacts()));
   contactEdited = new Contact();
   editContactId = 0;
   genderModel = new ArrayList<String>();
   genderModel.add("Male");
   genderModel.add("Female");
   return this;
 }
Пример #2
0
 /**
  * Check the contact form
  *
  * @throws ValidationException
  * @throws RemoteException
  */
 void onValidateFromContactForm() throws ValidationException, RemoteException {
   // personNumber can not be duplicated.
   if (isNewContact) {
     for (Contact con : contacts) {
       if (con.getPersonNumber() == contactEdited.getPersonNumber()) {
         throw new ValidationException(messages.get("person-number-already-exist-message"));
       }
     }
   }
   if (isApplyingContact || isDeleteContact) {
     // personNumber can be 0 in Sylvestrix
     if (contacts == null || contacts.size() == 0 || !contactSelected()) {
       throw new ValidationException(messages.get("select-row-message"));
     }
     if (isApplyingContact) {
       for (Contact con : contacts) {
         if (con.getContactId() != editContactId
             && con.getPersonNumber() == contactEdited.getPersonNumber()) {
           throw new ValidationException(messages.get("person-number-already-exist-message"));
         }
         // personal number can not be changed.
         if (con.getContactId() == editContactId
             && con.getPersonNumber() != contactEdited.getPersonNumber()) {
           throw new ValidationException(
               messages.get("person-number-can-not-be-changed-on-web-message"));
         }
       }
     }
     if (isDeleteContact) {
       boolean canContactBeDeleted =
           service.canContactBeDeleted(customer.getNumber(), contactEdited.getPersonNumber());
       if (!canContactBeDeleted) {
         throw new ValidationException(messages.get("contact-can-not-be-deleted-message"));
       }
     }
   }
 }
Пример #3
0
 Object onActionFromFinish() throws RemoteException {
   customer.setContacts(contacts.toArray(new Contact[contacts.size()]));
   service.updateContact(customer);
   cmpResources.discardPersistentFieldChanges();
   return SearchCustomer.class;
 }