Sunday, June 22, 2014

Re: GWT RequestFactory: IllegalArgumentException for setter only fields

See https://code.google.com/p/google-web-toolkit/issues/detail?id=5760

I don't get why having a getter "defeats the purpose". Just because you have a getter does not mean there's a value to get.
You could also have a setPassword "service method" instead (you can probably use your existing User#setPassword using an InstanceRequest<UserProxy,Void> setPassword(String password) method)

On Monday, June 23, 2014 12:05:34 AM UTC+2, Arpit wrote:
Why is it mandatory to have both getters and setters for a field in RF Proxy interfaces? For some fields (like plain text password), you want setters only.
e.g.

    @ProxyFor(value = User.class)
   
public interface UserProxy extends ValueProxy {
       
void setPassword(String password);
   
}


User class has both getters and setters.

   
public class User implements Serializable {
   
   
private String password;
   
   
public String getPassword() {
       
return password;
   
}
   
   
public void setPassword(String password) {
       
this.password = password;
   
}



When I set the password on proxy, I get an IllegalArgumentException:

    UserProxy user = userRequest.create(UserProxy.class);
    user
.setPassword("abc");



Above code results in following error:
java.lang.IllegalArgumentException: password
    at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.doCoderFor(AutoBeanCodexImpl.java:525)
    at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.setProperty(AbstractAutoBean.java:276)
...
...

This error goes away if I add a 'getPassword()' method in UserProxy interface but that defeats the purpose. Any help is appreciated. 

Thanks,
Arpit

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment