Friday, June 1, 2012

Re: Bean property being set to null by Editor framework even though it cannot be null



On Friday, June 1, 2012 12:31:42 PM UTC+2, Tiago wrote:
Hello Thomas,

On Friday, June 1, 2012 10:51:00 AM UTC+2, Thomas Broyer wrote:
Is X an EntityProxy or a ValueProxy? If it's a ValueProxy, then this is the expected behavior; you'll have to either:

It's a ValueProxy (X is not an entity).
Are you sure that an IllegalArgumentException with no message coming from a native method I didn't call directly is an expected behavior?

Yes.
  1. You create a ValueProxy, all its properties are 'null' by default
  2. You send it to the server; because it's a ValueProxy, all its properties have to be sent, so the unset property is sent with a 'null' value
  3. The RequestfactoryServlet / SimpleRequestProcessor creates a domain object and pushes the property values in it, so it tries to set the property to 'null'.
I think it's been suggested somewhere that we add the concept of "default values" to AutoBean and RF proxy properties, so you could annotate your X proxy to have the property default to some specific value, without the need to set it explicitly before sending it to the server. I can't find the enhancement request back (it does not seem to be in the issue tracker at least).
 
Shouldn't the framework just let the value defined in the constructor of the domain object,

No. Not for a ValueProxy.
 
or, if that's too complicated, try raising a better exception?

Well, it's your exception AFAICT.

  • set the property value to Boolean.FALSE on the client-side
I went for that one. You're right that it could be boolean though. It's just that in this project every domain property is a Boolean, never a boolean.
 
Also, I must declare the property in the proxy because, although the Editor I mention doesn't care about it, there are some points where I need to read the value of this property in the client-side.

You can have several proxy interfaces for the same domain object; if that can help in your case.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/eSi-1ef_ma8J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment