Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.i4u.qla.action.contract;
  2.  
  3. import javax.inject.Inject;
  4. import javax.inject.Named;
  5. import javax.faces.view.ViewScoped;
  6.  
  7. import com.i4u.app.base.BaseCrud;
  8. import com.i4u.app.domain.AppDomain;
  9.  
  10. import javax.transaction.Transactional;
  11. import javax.transaction.Transactional.TxType;
  12.  
  13. import com.i4u.qla.model.contract.CntContract;
  14.  
  15. @Named("contractCrud")
  16. @ViewScoped
  17. public class CntContractCrud extends BaseCrud<CntContract> {
  18.  
  19.     private static final long serialVersionUID = 1L;
  20.    
  21.     @Inject
  22.     private CntUI               ui;
  23.    
  24.     @Inject
  25.     private AppDomain           ad;
  26.    
  27.     @Override @Transactional
  28.     public String remove(CntContract inst) {
  29.         this.inst = entityManager.find(CntContract.class, inst.getId());
  30.         super.remove(this.inst);
  31.         return "";
  32.     }
  33.  
  34.     @Override
  35.     protected CntContract createInst() {
  36.         inst = new CntContract();
  37.         return inst;
  38.     }
  39.  
  40.     @Override
  41.     public void open(CntContract inst) {
  42.         setPrmTarget("adm.contract");
  43.         if (inst != null && inst.getId() != null) {
  44.             this.inst = entityManager.find(CntContract.class, inst.getId());
  45.         }
  46.         ui.setContractDialogRendered(true);
  47.     }
  48.  
  49. }
  50.  
  51.  
  52. /* #########################################################
  53. /*
  54. /*  and the remove method from super class:
  55. /*
  56.    #########################################################*/
  57.  
  58.     /**
  59.      * Remove.
  60.      *
  61.      * @param _inst
  62.      *            Instance to delete.
  63.      * @return Result.
  64.      */
  65.     public String remove(T _inst) {
  66.         try {
  67.             entityManager.remove(_inst);
  68.             entityManager.flush();
  69.             message(msg.get("msg.Successful"), msg.get("msg.Removed"));
  70.         } catch (Exception e) {
  71.                 fatalMessage(msg.get("msg.Failed"), msg.get("msg.Cannot remove"));
  72.                 e.printStackTrace();
  73.         } // block catch PersistenceException
  74.         return "";
  75.     }
  76.    
  77.     /**
  78.      * Method for removing from dialog form
  79.      */
  80.     public void remove() {
  81.         remove(inst);
  82.         cancel();
  83.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement