1 Reply Latest reply on Mar 15, 2013 3:38 PM by Jonathan Fuerth

    Implementing parent class for @Page annotated classes

    Viktor Chekh Newbie

      Hi guys!


      I am quite new to Errai so would like you to ask something. I have to make parent class for @Page annotated classes in my project and implement couple methods in there. Basically the main purpose of this class will be tracking time that user has spent on the particular page and showing which page user goes to after he left this one. I was able to track the time with using @PageShown  and @PageHiding annotiations. But now i have no idea how to implement functionality for showing the name of the page user goes to. Could you please share your thougths on this issue?


      Thanks, Viktor

        • 1. Re: Implementing parent class for @Page annotated classes
          Jonathan Fuerth Master

          Hey Viktor,


          Sounds like a great project! It can only lead to better UX insights when a dev team builds this kind of observability into an app!


          All four of the page state annotations permit the target method an optional parameter of type HistoryToken. If the parameter is present, the framework will pass in the history token that caused the page to show. This is useful in your case, but also in cases where not all history token key names are known at compile time (so @PageState fields can't be declared to accept their values).


          So try this:


          private void onPageShown(HistoryToken ht) {

             GWT.log("Page showing: " + ht.getPageName());



          Hope that helps!




          [edit: due to a temporary lapse in sanity, I originally used the nonexistant "@PageState" annotation in the code snippet]