View Javadoc

1   /**
2    *
3    */
4   package org.appfuse.webapp.client.ui.users.signUp;
5   
6   import org.appfuse.webapp.client.application.Application;
7   import org.appfuse.webapp.client.application.base.activity.AbstractProxyEditActivity;
8   import org.appfuse.webapp.client.application.base.security.LoginEvent;
9   import org.appfuse.webapp.client.proxies.UserProxy;
10  import org.appfuse.webapp.client.requests.UserRequest;
11  import org.appfuse.webapp.client.ui.home.HomePlace;
12  import org.appfuse.webapp.client.ui.login.LoginPlace;
13  import org.appfuse.webapp.client.ui.users.editUser.EditUserView;
14  
15  import com.google.gwt.event.shared.EventBus;
16  import com.google.gwt.place.shared.Place;
17  import com.google.gwt.user.client.ui.AcceptsOneWidget;
18  import com.google.inject.Inject;
19  import com.google.web.bindery.requestfactory.shared.Request;
20  import com.google.web.bindery.requestfactory.shared.RequestContext;
21  
22  /**
23   * @author ivangsa
24   *
25   */
26  public class SignUpActivity extends AbstractProxyEditActivity<UserProxy> implements EditUserView.Delegate {
27  
28      private final SignUpView signUpView;
29  
30      @Inject
31      public SignUpActivity(final Application application, final SignUpView editUserView) {
32          super(application, editUserView);
33          this.signUpView = editUserView;
34          this.setTitle(this.i18n.signup_title());
35          this.setBodyClassname("signup");
36          this.setDeleteConfirmation(this.i18n.delete_confirm(this.i18n.userList_user()));
37      }
38  
39      @Override
40      public String getSavedMessage() {
41          return this.application.getI18n().user_registered();
42      }
43  
44      @Override
45      public String getDeletedMessage() {
46          return this.application.getI18n().user_deleted(this.entityProxy.getUsername());
47      }
48  
49      @Override
50      public void start(final AcceptsOneWidget display, final EventBus eventBus) {
51          if (this.signUpView != null) {
52              this.signUpView.setAvailableRoles(this.application.getLookupConstants().getAvailableRoles());
53              this.signUpView.setCountries(this.application.getLookupConstants().getCountries());
54          }
55          super.start(display, eventBus);
56      }
57  
58      @Override
59      public void updatePasswordClicked() {
60      }
61  
62      @Override
63      protected String getEntityId() {
64          // return a not null entityId so super does not try to create a new
65          // profile
66          return "x";
67      }
68  
69      @Override
70      protected RequestContext createProxyRequest() {
71          return this.requests.userRequest();
72      }
73  
74      @Override
75      protected Request<UserProxy> loadProxyRequest(final RequestContext requestContext, final String proxyId) {
76          return ((UserRequest) requestContext).signUp();
77      }
78  
79      @Override
80      protected RequestContext saveOrUpdateRequest(final RequestContext requestContext, final UserProxy proxy) {
81          ((UserRequest) requestContext).signUp(proxy);
82          return requestContext;
83      }
84  
85      @Override
86      protected RequestContext deleteRequest(final RequestContext requestContext, final UserProxy proxy) {
87          throw new UnsupportedOperationException();
88      }
89  
90      @Override
91      protected Place previousPlace() {
92          return new LoginPlace();
93      }
94  
95      @Override
96      protected Place nextPlace(final boolean saved) {
97          this.eventBus.fireEvent(new LoginEvent());
98          return new HomePlace();
99      }
100 
101 }