0 Replies Latest reply: Sep 5, 2012 12:48 AM by AtulSingh RSS

    Change handler handleRegisteredChange() method

    AtulSingh
      I have create a validation in which number of tender deposit >= tender control list

      I have override handleAddOrChange() method on deleting tender deposit list validation is fire before saving the data so due to which number of tender deposit list count is coming wrong.

      For example if number of tender control is 2 and number of tender deposit is also 2.
      On deleting one tender deposit list(now 2-1 = 1) and click on save button the number of teder deposit is coming 2.
      Since validation is fire before saving data.


      This type of child list validation is handle by handleRegisteredChange() method in change handler.
      But this method is triggered only if it is called by BusinessEntity(DepositControl).registerChange(change); method.

      But what is change parameter and how to make this parameter, I am not getting. So please if any body have idea regarding this. Below is the code--

      /*
      * @ChangeHandler (entityName = depositControl)
      */
      public class CmDepositControl_CHandler extends AbstractChangeHandler<DepositControl>{
           private static final Logger logger = LoggerFactory.getLogger(CmDepositControl_CHandler.class);
           
           @Override
           public void handleAddOrChange(DepositControl dcEntity, DataTransferObject<DepositControl> prevDto) {
                // TODO Auto-generated method stub
                super.handleAddOrChange(dcEntity, prevDto);
                
                logger.info("[===] Inside handleAdd or Change");
                /*if(getOpenDepositControl(dcEntity) > 1)
                     addError(CustomMessageRepository.oneOpenCashierControlAllowed());*/
                
                if(getTenderControls(dcEntity) > getTenderDeposits(dcEntity))
                     addError(CustomMessageRepository.tndCtrlDepCtrlCompare());
                
                logger.info("[===] Complete");
                
                
                try {
                     logger.info("[===] Before registerChange");
                     dcEntity.registerChange(change); ///////// how to create this change parameter
                } catch (InstantiationException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                } catch (IllegalAccessException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                }
           }

      Edited by: Atul Singh on Sep 4, 2012 10:38 PM