I have a GWT form that changes some fields depending on what is selected in it. The form uses the Editor, Driver GWT module
The story is a person who edits her profile, and says: "I'm a User" or "I'm a Seller" (eventually "I'm something else") So depending on this choice that is in the form it self, I want to change some editors in the view (first name, last name for a person become company name, taxes serial number, while many other fields remain the same but change their place). I made two sets of UiBinder screens (one for each profile). And I have a main UiBinder that contains the checkbox "I'm a company" that handles those subeditors
What I thought I could do until now is that I have a ValueAwareEditor with subeditors
@Path("")
@UiField
protected CompanyBasicInfo basicInfoComp;
@Path("")
@UiField
protected PersonBasicInfo basicInfoPers;
both are filled by the driver, but only one of them is visible.
The thing is that I don't like the idea of having the same property in many editors, neither the performance this approach could imply
On the other side, CompanyBasicInfo and PersonBasicInfo are regular Editor implementations. So putting @Ignore on both of them is not possible since I cannot call a setValue() on them when I will want.
Also making them implement ValueAwareEditor is not clear to me since the contain regular Editor widgets, so I still won't be able to call setValue() on their fields : I'm just moving the problem a step further...
In the view I also don't have access to the Driver to call edit() again. I took a look at how it is done in the lists but there are too much new concepts, I don't think I have to learn all that code just to be able to handle this simple case
Thanks for you answers
Since the editor framework will work on the same object that you have delivered into the editor, you can savely add the missing parts during editing.
I think, I would try to resolve it either with the OptionalFieldEditor, or with a combination of ValueAwareEditor and Subeditors.
The main structure could be something like
The Editor will then implement at least ValueAware
The subeditors should be
IsEditor<OptionalFieldEditor>. You can find samples of OptionalFieldEditors on the gwtproject page, iirc.Hope this helps you forward.