Hi,

I'm following the Expenses Sample that can be found in the SDK. I'm
writing a demo in which I would authenticate the user via GAE Users
Service.
I hit some problem in which the UserService userService =
UserServiceFactory.getUserService() is always null in the Service
Locator part of the Request Factory anyway here are my sample code.

This are my server side code.

package **.server;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.google.web.bindery.requestfactory.shared.ServiceLocator;

/**
 * Gives a RequestFactory system access to the Google AppEngine
UserService.
 */
public class UserServiceLocator implements ServiceLocator {
        public UserServiceWrapper getInstance(Class<?> clazz) {
                final UserService userService = 
UserServiceFactory.getUserService();
                return new UserServiceWrapper() {

                        public String createLoginURL(String destinationURL) {
                                String loginURL = 
userService.createLoginURL(destinationURL);
                                return loginURL;
                        }

                        public String createLogoutURL(String destinationURL) {
                                String logoutURL = 
userService.createLogoutURL(destinationURL);
                                return logoutURL;
                        }

                        public User getCurrentUser() {
                                User user = userService.getCurrentUser();
                                return user;
                        }
                };
        }
}


public interface UserServiceWrapper {
  public String createLoginURL(String destinationURL);

  public String createLogoutURL(String destinationURL);

  public User getCurrentUser();
}


And here is my shared folder code

package **.shared;

import com.google.web.bindery.requestfactory.shared.ProxyForName;
import com.google.web.bindery.requestfactory.shared.ValueProxy;

/**
 * Client visible proxy of Google AppEngine User class.
 */
@ProxyForName("com.google.appengine.api.users.User")
public interface GaeUserProxy extends ValueProxy {
  String getNickname();
  String getEmail();
}


import com.google.web.bindery.requestfactory.shared.RequestFactory;

public interface MercadoRequestFactory extends RequestFactory{

//      UserEntityRequest userEntityRequest();
        GaeUserServiceRequest userServiceRequest();
}

And here is how I instantiate it using GIN

package **.client.ioc

@Provides
        @Singleton
        public RequestFactory getRequestFactory(EventBus eventBus) {
                RequestFactory requestFactory = GWT.create(RequestFactory 
.class);
                requestFactory.initialize(eventBus);
                return requestFactory;
        }

And here is how I use this in my client

package **.client.view

@Inject
        RequestFactory requestFactory ;

@Override
        public void setUser() {
                gaeUserServiceRequest = requestFactory.userServiceRequest();
                gaeUserServiceRequest.getCurrentUser().to(new
Receiver<GaeUserProxy>() {

                        @Override
                        public void onSuccess(GaeUserProxy response) {
                                if(response == null) {
                                        signingLink.setText("Sign In");
                                        lblUserEmailAddress.setText("Guest");
                                        createLoginURL();
                                } else {
                                        signingLink.setText("Sign Out");
                                        
lblUserEmailAddress.setText(response.getNickname());
                                        createLogoutURL();
                                }
                        }
                });

                gaeUserServiceRequest.fire();
        }

The problem here is the GaeUserProxy response is always null. I trace
the problem and found out that the  UserService userService =
UserServiceFactory.getUserService() in my server side
UserServiceLocator  is always null. What seems to be the problem?

I'm using the GWT 2.4 BTW.


TIA

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to