Monday, January 31, 2011

Re: GWT 2.1.1 EditorFramework CellList editor using SimpleBeanEditorDriver and JSON help...

I couldn't manage to work Editor framework with view interfaces (It doesn't mean it's impossible, I hope it isn't or it won't be). Try not to extend the Editor<Module> in your view interface, but implement it in the view implementation. I know it looks ugly, that's why I've created a seperate "editor widget" which is included in the View.

Let me know how it goes.

On Mon, Jan 31, 2011 at 3:31 AM, Milan Cvejic <liquidbrainz@gmail.com> wrote:
Hi everyone,
I can't manage to make editing of CellList using
SimpleBeanEditorDriver. I tried everything and now looking for some
help, and guidelines.

I am trying to create view that will display two text fields and one
CellList widget that will display some Labels.

I managed to create editor for text fields, but can't manage to create
editor for CellList. Here is my code...
/* Basic object that need editor */
public class Module {
       private int id;
       private String name;
       private String description;
       private List<Label> fields;

       (getters and setters methods)
}

/* Basic interface that editor will use */
public interface ModulesDetailView extends IsWidget, Editor<Module> {
         @Path("name")
         IsEditor<ValueBoxEditor<String>> getNameEditor();

         @Path("description")
         IsEditor<ValueBoxEditor<String>> getDescriptionEditor();

         /* This is a part where i have problems */
         @Path("fields")
         IsEditor<ListEditor<Label, Editor<Label>>> getFieldsEditor();
}

/* View Implementation */
public class ModulesDetailViewImpl implements ModulesDetailView {

       private static ModulesDetailViewImplUiBinder uiBinder =
GWT.create(ModulesDetailViewImplUiBinder.class);
       private final HTMLPanel moduleDetailPanel;

       @UiField TextBox name;
       @UiField TextBox description;
       @UiField(provided=true) CellList<Fields> fields = new
CellList<Fields>(new AbstractCell<Fields>(){

               @Override
               public void render(Context context,
                               Fields value, SafeHtmlBuilder sb) {
                       AbstractCell<String> c = new EditTextCell();
                       c.render(context, value.getName(), sb);
               }

       });

       interface ModulesDetailViewImplUiBinder extends UiBinder<HTMLPanel,
ModulesDetailViewImpl> {
       }

       public ModulesDetailViewImpl() {
               moduleDetailPanel = uiBinder.createAndBindUi(this);
       }

       @Override
       public Widget asWidget() {
               return moduleDetailPanel;
       }

       @Override
       public IsEditor<ValueBoxEditor<String>> getNameEditor() {
               return name;
       }

       @Override
       public IsEditor<ValueBoxEditor<String>> getDescriptionEditor() {
               return description;
       }

       /* implemented method from interface (this is where I stuck)*/
       @Override
       public IsEditor<ListEditor<Label, Editor<Label>>> getFieldsEditor() {
               return null;
       }
}

As you can see from comments in code, i am having problem with
defining method for getting editor for CellList. Currently method
getFieldsEditor is completely wrong, as i tried various things, but
without success. I have logic that gets object from server, populate
Module object, and populate name and description, but can't manage to
populate CellList with list of retrieved data.

I am using JSON and SimpleBeanEditorDriver as my code on server is
PHP.

Thanks for time reading this, and thanks any help.

--
Milan Cvejic

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
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.




--
Üdv,
Kriván Bálint

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
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