View Javadoc

1   /**
2    * 
3    */
4   package org.appfuse.webapp.client.ui.login;
5   
6   import com.google.gwt.place.shared.Place;
7   import com.google.gwt.place.shared.PlaceTokenizer;
8   import com.google.gwt.place.shared.Prefix;
9   
10  /**
11   * @author ivangsa
12   *
13   */
14  public class LoginPlace extends Place {
15  
16      private static final String TOKEN_PREFIX = "login";
17      private static final String FULL_TOKEN_PREFIX = TOKEN_PREFIX + ":";
18  
19      private String historyToken = "";
20  
21      public LoginPlace() {
22          super();
23      }
24  
25      /**
26       * Constructor with a history token to redirect after successful login.
27       * 
28       * @param loginHistoryToken
29       *            history token to redirect after successful login.
30       */
31      public LoginPlace(String loginHistoryToken) {
32          super();
33          if (loginHistoryToken != null) {
34              if (loginHistoryToken.startsWith(FULL_TOKEN_PREFIX)) {
35                  this.historyToken = loginHistoryToken.replaceFirst(FULL_TOKEN_PREFIX, "");
36              } else {
37                  this.historyToken = loginHistoryToken;
38              }
39          }
40      }
41  
42      public String getHistoryToken() {
43          return historyToken;
44      }
45  
46      @Prefix(TOKEN_PREFIX)
47      public static class Tokenizer implements PlaceTokenizer<LoginPlace> {
48          @Override
49          public String getToken(LoginPlace place) {
50              return place.historyToken;
51          }
52  
53          @Override
54          public LoginPlace getPlace(String token) {
55              return new LoginPlace(token);
56          }
57      }
58  
59      @Override
60      public boolean equals(Object obj) {
61          return false;// allow go to same place
62      }
63  }