Ticket #481 (closed defect: fixed)
Unable to cancel navigation when handling OnSideBarButtonClickEvent
| Reported by: | hozn | Owned by: | xue |
|---|---|---|---|
| Priority: | urgent | Milestone: | 3.0.7 |
| Component: | Prado Framework v3 | Version: | 3.1 |
| Severity: | major | Keywords: | wizard event bubble |
| Cc: |
Description
I noticed this unanswered post on the forum: http://www.pradosoft.com/forum/index.php/topic,5754.msg25986.html#msg25986
Here's the relevant bug report (which I've taken the liberty of editing as I think there were a few mistakes in the report):
I have a function associated with the OnNextButtonClickEvent of a Wizard in order to validate and control the flow of the wizard.
The wizard is very simple just 2 steps, So i just control one 'NextButton?'. In the handler of the OnNextButtonClickEvent i set the property $param->CancelNavigation to true [HL edit] in order not to chage the step when the validation has failed.
The problem is that I do exactly the same thing with the handler of the OnSideBarButtonClickEvent ($param->CancelNavigation = true [HL edit]), but the wizard changes the step. It doesn't cancel the navigation.
Indeed, I was able to replicate this problem very easily. In looking into the matter further, I was finally able to determine that the problem is that the (CMD_MOVETO) event fired from the DataListItem was actually being caught twice: first by the TWizard->dataListItemCommand() method (which handled the $param->CancelNavigation correctly), and then by the TWizard->bubbleEvent() method (which was re-evaluating the event & not correctly handling the $param->CancelNavigation).
I don't know what the correct fix for this problem is. I was able to fix it by simply returning (true) from the TWizard->bubbleEvent() method if the command was CMD_MOVETO. I haven't thoroughly tested that solution, however, so I don't know whether I'm overlooking some other functionality.
I will attach that simple patch to this ticket.
