I'm working on modifying a jsf-1.2 application for use on a tablet pc.
For that purpose I have made the rows of a table clickable to open the detail view of the rows contents, rather than have the user click on a link in that table (which is the case in the Desktop Version).
It works fine so far. Each row can, however, contain two rich-buttons that open a different link.
The contents of that link is opened in a new tab, like it's supposed to. My problem is, that the action event of the rowclick is activated in the original tab as well, which is not the intended behaviour.
What I want to do now is stop the event if one of the buttons in the row is clicked.
I know already, that the event of the butons is fired before the rowclick event. Is there a way to just cut the event chain at this point?
I don't know if you can break the chain - but even if it is possible (probably by throwing an exception) - I would recommend against it.
The proper (sadly) way to do it in an event-driven environment is to set some
boolean
indicator to be true when a handler for a button fires, and set it back to false when the handler finishes its job. In the handler for therow-clicked
event, you need to check to see if theboolean
is true - and only if it is false - continue with handling therow-clicked
event.A suggested name for the boolean:
isRowButtownClicked
Disclaimer: I'm basing this answer on my knowledge in C# - I do not have any experience in GUI development in Java and specifically not in JSF.
This happens due to Event Bubbling. Try using
Event.stop(event);
in yourcommandButton
as below.