| Summary: | IBrowserRidget - API to intercept and prevent URL changes | ||
|---|---|---|---|
| Product: | [RT] Riena | Reporter: | Elias Volanakis <elias> |
| Component: | ridget | Assignee: | Elias Volanakis <elias> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | 3.0.0 | ||
| Hardware: | PC | ||
| OS: | Windows Vista | ||
| Whiteboard: | |||
|
Description
Elias Volanakis
Committing 1st implementation.
Example Snippet:
browserRidget.addLocationListener(new ILocationListener() {
public boolean locationChanging(final LocationEvent event) {
System.out.println(event);
final String msg = String.format("Go to:\n\n'%s' ?", event.getLocation());
return MessageDialog.openQuestion(shell, "Confirm Change", msg);
}
});
Technical notes:
- The listener cannot prevent _some_ changes. For example: clicks that trigger javascripts (dom changes) or that open urls with <a href="" target="_blank"> do not fire events and therefore cannot be caught
- Per design - changing the URL via API calls (i.e. setUrl(...), setText(...)) does not fire events or notify the listener. This is constintent with SWT patterns, to avoid endless listener-event-listener loops.
- Per design - rebinding the ridget to another browser widget does not notify the listeners. (though this could be discussed)
Notes: - added LocationEvent.isAllowed() flag - this can be used to check if another listener has already vetoed the change. - added ILocationListener.locationChanged() to receive notification of successful url changes - this is equivalent to browserRidget.addPropertyListener(IBrowserRidget.PROPERTY_URL, lsnr); Resolved. |