On Thursday, November 15, 2012 8:20:05 AM UTC+1, Aleks wrote:
>
> Hi all,
>
> I've only recently started playing with GWT editors and have run into what 
> I think is a simple problem but have not been able to find a solution to 
> it. 
>
> Basically, I have the class Person/Address scenario, with a 
> PersonEditor/PersonValueProxy and AddressEditor/AddressValueProxy. The 
> AddressEditor is a subeditor within PersonProxy.
>
> My issue is that when I load the editor, the PersonProxy is not null (I 
> create it first), but the AddressProxy is null. Even if I add values in the 
> address form, the AddressProxy remains null.
>
> I would like to get at least one of the following two working:
>
> 1. What I would really like is to have an AddressProxy created IF the user 
> has populated any address fields in the form. 
>
> 2. If that is not possible, I would at least like an AddressProxy 
> automatically created when I start the PersonEditor - or as a general rule 
> I would like all sub-objects to be created once an editor for the parent 
> container is created.
>
> Now, I did manage to create an AddressProxy object and the PersonEditor 
> seemed to recognize this (there were no more validation errors saying 
> "address is null"), however it seems as if the AddressEditor knows nothing 
> about this. 
> I say this because Address has validations such as "streetname cannot be 
> null" and that error keeps appearing even if I do enter a street name in 
> the form - so it seems that the proxy object is somehow detached from the 
> AddressEditor?!
>
>
> Note that I wouldn't like to have to create all possible proxies before I 
> load the editor - I would much rather create them on demand, as new editors 
> are loaded.
>
> In case I didn't make much sense:
>
> *public class PersonEditor extends Composite implements  
> Editor<PersonProxy> {
>
> @UiField
> AddressEditor address;
> ....
> }
>
> public class AddressEditor extends Composite implements  
> Editor<AddressProxy> {
> ...* *
> }*
>
> Is there a standard best practice for achieving this..Or forget best 
> practice - something that works? :)
>

I remember having answered the exact same question some months ago, either 
here or on StackOverflow.

Things to look at (from memory): OptionalFieldEditor (possibly extend it to 
automatically create an AddressProxy in setValue when called with null); if 
you want the AddressProxy to be created only when fields are not 
null/empty, then create a class that implements AddressProxy, that you edit 
when the original value is 'null', and on flush() check whether it's empty 
or not and decide whether to create a "real" AddressProxy.

-- 
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/-/rFGl99omcy4J.
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