Monday, August 19, 2013

Re: Need Editor Framework help

In my humble opinion, the editor framework is by far one of the cooolest and most important features found in GWT. For some reason it doesn't seem to be something that gets used a lot, at least I haven't seen a lot of people using it. 

Your questions:

1) It doesn't have to be used with UI Binder. It can work just fine with plain java views.
2) No
3) The Editor framework is mostly if not all about data binding.

My very simplistic, in a nut shell Editor description.

- Suppose you have a View and it consists of a Label, checkbox, texarea, etc...
- That View that you want the user to interact with is what is called an Editor in the examples you'll find. For example in http://www.gwtproject.org/doc/latest/DevGuideUiEditors.html :
  public class PersonEditor extends Dialog implements Editor<Person> {
 - That View/Editor will have fields representing ... well what you want your view to look like.

- You will back that Editor/View with a Java Bean. In this case Person. The field names in your editor/view must match the Bean fields. Although I think there was even an annotation as well that you could use if you wanted to use a different field name. (Getting old so I forget stuff)

- So now you have a View/Editor that is being backed up or better expressed it's bound with a Java Bean.

- At this point all you really need to remember for the most part are two methods.

a) edit    => will populate your View/Editor fields based on the value/s found in your Java Bean (Person in this case)
b) flush  => The other direction, will take the values from your View/Editor html elements and populate your Bean instance.

There are more complicated cases. Editors of Editors, a few other things, but overall and again very simplistically that is the idea.

See an example on how we employ the Editor framework for example in this View we have in the touch4j demo:


Click/Tap on source on the right hand corner.

I omitted some initialization steps in my very poor description such as an interface definition, etc... but overall that is the idea.

For your case, you can publish events for example on your RPC response containing the DTO you've received and the different presenters can have or react to those events you published, build beans that back up your Editor/View and update them in a very simple way. Think about what would happen without the Editor framework. You would need to have in your different presenters:

onReceivedEvent(Person person) {
   firstNameLabel.setValue(person.getFirstName);
   // If you have a lot of html elements in your view this is tedious work.
   // More so if you have to check for nulls etc...
}

With the Editor framework that becomes:

onReceivedEvent(Person person) {
   yourEditorDriver.edit(person);
   // Your UI elements are automatically updated
}

Then to obtain any user driven interactions with your UI HTML elements you could have something like after the user hits Save:

onSaveEvent() {
   Person edited = yourEditorDriver.flush();
   firePersonPersistEvent(edited);
   // All the UI changes that were done by the user are automatically updated in the Person Bean.
}

Hope that helps.



On Mon, Aug 19, 2013 at 6:44 PM, Michael Prentice <splaktar@gmail.com> wrote:
I spent most of Friday reading up on Editor Framework and it seemed quite powerful and useful. But today I'm looking at actually making use of it and I've had some fairly basic questions which I have not been able to find answers to in this group or anywhere on Google/gwtproject.org.

1) Does the use of Editor Framework require the use of UiBinder? i.e. can I use it with a regular Java view?
2) Does the use of Editor Framework require the use of RequestFactory? This answer appears to be no, but I haven't been able to find any examples that don't use RequestFactory. Do such examples exist?
3) What options exist in GWT for doing databinding? It looks like UiBinder itself takes care of doing data binding. So I guess that Editor Framework is not so much about data binding, instead it adds validation, Editor composition, and?

I still can't really figure out if the Editor Framework is right for my project or not. I use DTOs via GWT-RPC without any RequestFactory. My current views are Java (no UiBinder) but I might switch to UiBinder. I've got the architecture for MVP laid out pretty well and I'm having a hard time figuring out how Editors fit into the mix.

The DTOs whose data is exposed in my views does not map directly to what is displayed in the view one-to-one. Many views display data taken from multiple DTOs. Also actions/selections in one view must result in changes to other views on the page. This means that selecting an item in one view could cause (via Events) multiple presenters to disable/enable elements in their views.

Are there are good IO videos that cover Editor Framework in detail? So far my searches have not come up with any, but the names don't always specify the content.

I've read the details on gwtproject.org, code.google.com, and various blogs plus the DynaTableRf example. But while trying to implement this stuff today, it just feels wrong, like it isn't going to fit/work/etc with what I'm doing. So I'm trying to figure out if I should just not use Editor Framework at all.

Thank you,

Michael Prentice
GDG Space Coast

--
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/groups/opt_out.



--
Alfredo Quiroga-Villamil

AOL/Yahoo/Gmail/MSN IM:  lawwton

--
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/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate