Beispiel #1
0
 public void prepareEdit() {
   if (current != null) {
     selectedItemIndex = intValue(current.getId());
     this.prepareSelectControlDisable();
   } else {
     JsfUtil.addErrorMessage(new MessageProvider().getValue("nothingToEdit"));
   }
 }
Beispiel #2
0
 public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
   if (object == null) {
     return null;
   }
   if (object instanceof Atm) {
     Atm o = (Atm) object;
     return getStringKey(o.getId());
   } else {
     throw new IllegalArgumentException(
         "object "
             + object
             + " is of type "
             + object.getClass().getName()
             + "; expected type: "
             + AtmController.class.getName());
   }
 }
Beispiel #3
0
 public DataModel searchItems() {
   recreateModel();
   if (items == null) {
     if (selectText.equals("")) {
       items = new ListDataModel(getFacade().findAll("name", true));
     } else {
       items = new ListDataModel(getFacade().findAll("name", "%" + selectText + "%", true));
       if (items.getRowCount() > 0) {
         items.setRowIndex(0);
         current = (Atm) items.getRowData();
         Long temLong = current.getId();
         selectedItemIndex = intValue(temLong);
       } else {
         current = null;
         selectedItemIndex = -1;
       }
     }
   }
   return items;
 }
Beispiel #4
0
 public void saveSelected() {
   if (sessionController.getPrivilege().isMsEdit() == false) {
     JsfUtil.addErrorMessage("You are not autherized to make changes to any content");
     return;
   }
   if (selectedItemIndex > 0) {
     getFacade().edit(current);
     JsfUtil.addSuccessMessage(new MessageProvider().getValue("savedOldSuccessfully"));
   } else {
     current.setCreatedAt(Calendar.getInstance().getTime());
     current.setCreater(sessionController.loggedUser);
     getFacade().create(current);
     JsfUtil.addSuccessMessage(new MessageProvider().getValue("savedNewSuccessfully"));
   }
   this.prepareSelect();
   recreateModel();
   getItems();
   selectText = "";
   selectedItemIndex = intValue(current.getId());
 }