Hi,

I am using mongodb via morphia, and the @Id of a collection/table in
the mapping class is a custom ObjectId class, not a primitive type. Is
is possible to use it in RequestFactory?

I tried using GWT 2.4 rc1, and I am getting the following error code
in

Caused by: java.lang.NullPointerException: null
    at com.test.client.Test$1MyHandler$1.onSuccess(Test.java:189)

In the code below

                                final ObjectIdProxy objectIdProxy =
request.create(ObjectIdProxy.class);
                                objectIdProxy.set_inc(tempObjectId.get_inc());
                                
objectIdProxy.set_machine(tempObjectId.get_machine());
                                objectIdProxy.set_time(tempObjectId.get_time());
                                request.findEmployee(objectIdProxy).fire(new
Receiver<EmployeeProxy>() {

                                        @Override
                                        public void onSuccess(EmployeeProxy 
response) {
                                                dialogBox.setText("Remote 
Procedure Call");
                                                
serverResponseLabel.removeStyleName("serverResponseLabelError");
                                                
serverResponseLabel.setHTML(response.getId().get_time() + "==" +
tempObjectId.get_time() );    <------------------ null exception in
this line
                                                dialogBox.center();
                                                closeButton.setFocus(true);
                                        }


it seems like the id is not transferred backed from server to client
although I am able to pass the ObjectIdProxy to the server, but when
the server return the objectId included in the Employee object, it
seems like the client side is not able to pick it up, the
response.getId() return null and hence the error, if I changed to
response.getUserName() it is working perfectly.


@Entity
public class Employee {

        // just a dump that return the record
        public static Employee findEmployee(ObjectId id) {
                if (id == null) {
                        return null;
                }

                Employee employee = new Employee();
                employee.setId(id);
                employee.setDepartment("test");
                employee.setUserName("Andy" + id.get_time());
                employee.setVersion(System.currentTimeMillis());
                return employee;

        }

        public void persist() {
                // do nothing
        }

        private String userName;

        private String department;

        @Id
        private ObjectId id;

        @Version
        private Long version;

.......
}

---------------------------------------------------------------------------------------------------------------------------------

@ProxyFor(com.test.server.Employee.class)
public interface EmployeeProxy extends EntityProxy {

        String getDepartment();

        ObjectIdProxy getId();

        String getUserName();

        void setDepartment(String department);

        void setUserName(String userName);

        EntityProxyId<EmployeeProxy> stableId();
}

---------------------------------------------------------------------------------------------------------------------------------------

ObjectId class is very long, but basically only use 3 field and we can
use it in the server perfectly.
Could you please advice what I have do wrong or if there are any
alternative ways?

Kind Regards
Andy

-- 
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