public String getSelectedCreditCardType() {
   String selectedCCType = null;
   if (customer.getCreditCardType() != null) {
     selectedCCType = getCCTypeLabel(customer.getCreditCardType());
   }
   return selectedCCType;
 }
 public void useCreditCardChanged(ValueChangeEvent ev) {
   Boolean useCreditCard = (Boolean) ev.getNewValue();
   if (useCreditCard != null) {
     customer.setUseCreditCard(useCreditCard);
   }
   FacesContext.getCurrentInstance().renderResponse();
 }
 public String getPreferredCategoriesString() {
   StringBuilder categories = new StringBuilder();
   List<String> prefCats = customer.getPreferredCategories();
   if (prefCats != null) {
     for (String cat : prefCats) {
       if (categories.length() > 0) {
         categories.append(", ");
       }
       categories.append(getCategoryLabel(cat));
     }
   }
   return categories.toString();
 }
 public void validateCreditNumber(FacesContext ctx, UIComponent component, Object value)
     throws ValidatorException {
   // Only validate credit card data if user specified to use it
   CreditCardType ccType = (CreditCardType) creditCardTypeInput.getValue();
   Boolean useCC = customer.getUseCreditCard();
   if (useCC != null && useCC && ccType != null) {
     // Check credit card number
     int length;
     if (ccType == CreditCardType.CARD_A) {
       length = 4;
     } else {
       length = 5;
     }
     String ccNumber = (String) value;
     if (ccNumber != null && !ccNumber.matches("\\d{" + length + "}")) {
       FacesMessage msg =
           GuiUtil.getFacesMessage(
               ctx, FacesMessage.SEVERITY_ERROR, "validateCreditCardNumber.NUMBER", length);
       throw new ValidatorException(msg);
     }
   }
 }
 public String getSelectedGender() {
   return customer.getGender() != null ? getGenderLabel(customer.getGender()) : null;
 }