Allow overriding onSubmit event in dialogs.

Fixes #2327 , #2326 

@dinhviethoa PTAL thanks.
Thanks for the suggestions.

 I think moving it to a private method will work best. This will allow derived classes to override `_commit()` while maintaining the default behavior.

Also I think we should be passing in the event to commit, in case `_commit()` wants  to handle it.