Wednesday, October 8, 2014

Re: Ignore place change on bookmark click

The solution was to modify the DefaultHistorian by overriding addValueChangeHanlder. I was then able to inspect the value change event before passing it along to the PlaceHistoryHandler.
PlaceHistoryHandler historyHandler=new PlaceHistoryHandler(getPlaceHistoryMapper(),getHistorian());

public Historian getHistorian() {
return new PlaceHistoryHandler.DefaultHistorian(){
@Override
public HandlerRegistration addValueChangeHandler(final ValueChangeHandler<String> valueChangeHandler) {
//The PlaceHistoryHandler will be adding this ValueChangeHandler. Override and inspect the ValueChangeEvent before alerting the PlaceHistoryHandler that there has been a change.
return super.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
if(event.getValue().toLowerCase().equals("toc")  //Ignore table of contents navigation event.
|| event.getValue().indexOf(WcagHelper.HYPERLINK_PREFIX)>=0){  //Ignore specially marked hyperlinks.
return;
}
//We made it this far so it is safe to pass the navigation event along.
valueChangeHandler.onValueChange(event);
}
});
}
};
}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment