good to know

On Saturday, August 25, 2012 2:57:16 PM UTC-7, Arash wrote:
>
> Thank you Thomas for your elaborate response. I had to implement your 
> solutions to fully grasp the idea. I summarize the result here for anyone 
> who may be interested:
> OptionalFieldEditor is an elegant solution to dynamically create non 
> existing proxies (Thomas's second solution). It takes care of attaching the 
> newly created address proxy to the personProxy (automatically) so you don't 
> have to actually make the assignment. This is what you need:
>
> public class OptionalAddressEditor extends 
> OptionalFieldEditor<AddressProxy, AddressEditor>
> implements HasRequestContext<AddressProxy>, IsWidget {
> ...
>     @Override
>     public Widget asWidget() {
> return this.addressEditor;
>     }
> }
> To be able to use this field as part of your view /uiBinder you have to 
> extend isWidget and return the actual addressEditor (passed in as part of 
> the constructor) via asWidget(). 
> There are three possible scenarios here: New Person/New Address, Edit 
> Person/New Address, Edit Person/Edit Address.
> To be able to grab the address editor changes via the context, it seems 
> trivial to create the AddressProxy (if non existent) prior to editing. The 
> problem with this approach is that if you create a Person from scratch or 
> if personProxy has no addressProxy already attached to it, and user don't 
> fill out the address at all, you have already created an addressProxy which 
> haunts you in validation (I don't know how to get around this one). Even 
> returning null after flushing and before firing the context has no affect. 
>
> To get around the validation issue, fake addressProxy seems to be the 
> solution but If your validation resides on the server (like my scenario), 
> there is no way to avoid actually saving the fake proxy. Your fake proxy 
> needs to go all the way to the db since your sql carries the constraint as 
> well and that means you have to interpret the fake values. 
> In the client, upon rendering the "fake address proxy" recognize the fake 
> value and empty out the fields. (setValue of the optionalFieldValue).
>
> Thank you Thomas again, it has been a good learning process but with the 
> limitations we have, I resort to removing all the constraint on the Address 
> domain, at this point it seems to be the lesser of the evils. 
>

-- 
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/-/2CvQZbc8914J.
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