Monday, 27 May 2013

49.CODING FOR EDIT, CANCEL AND SAVE BUTTON EVENT HANDLERS



We have added three buttons EDIT, CANCEL and SAVE buttons to the over view page in the previous tutorial. 

Let us code in the event handlers of those buttons.

Go to the component and overview page and create event handlers with name ‘EDIT’, ‘CANCEL’ and ‘SAVE’.  (Event handler names are case sensitive;all these name of event handlers should match with on click properties of buttons that we have created in the previous chapter).
EDIT event handler. 


Write the following code in the event handler. 





First we are reading current record from the context node HEADER into LR_ENTITY.
Next, we are checking, it is bound or not. 

Next we are using method IS_CHANGE_ALLOWED or not, if change is allowed, then we are applying LOCK on that record. 

Next if lock is successful, using VIEW_GROUP_CONTEXT, we are setting all views editable else we are just resetting the view group context, which put all views into display mode. 

CANCEL event handler:






We are reading the current record and getting the instance of transaction from it. calling the revert method will cancel all the changes that we have done. 

Calling reset method will put all views into display mode. 

SAVE event handler:







We are reading the current record from the context node.  If node is bound, then we are taking the transaction context of it. 

If it is initial, then we are asking core class to provide the transaction context.
Then we are checking whether save operation is possible or not using CHECK_SAVE_POSSIBLE method. If we can save the transaction, then we are calling SAVE method and commit the work with one more method COMMIT. 

One save is done, then put all views into display mode by resetting the view group context.

Activate all methods and test the application.
Clicking on EDIT button will make all views shift into edit mode. 





Press cancel button, all views will go into display mode. 

Next , we will learn one important topic called UI OBJECT TYPE. 


7 comments:

  1. Hello,

    Excellent Job with the blog dear.. God Bless !!! Keep it up..
    I still have a lot pages to cover it seems...

    ReplyDelete
  2. Awesome blog! keep going..
    Cheers!!

    ReplyDelete
  3. Hello,

    excellent work, thanks a lot.

    ReplyDelete
  4. Hey ,Very nice bogs,but images are not displying in all the systems ,It works fine ,in my laptop and it is not displayinginages in other systems thought settings changed,so,please let us know,what kind of settings needs to change to disply in images .

    ReplyDelete
  5. me->typed_context->header is not working. Instead I've used me-typed_context->buttons where 'buttons' is the new context that I've created in previous section, 48. I've created it in the Overview Page context and bind it to the header context in component. Is there something I've done wrong?

    ReplyDelete