ListEditor question.

52 views
Skip to first unread message

Daniel Mauricio Patino León

unread,
Apr 9, 2012, 4:08:04 PM4/9/12
to google-we...@googlegroups.com
Hello Every one.

I have a problem with ListEditor. The case is this:

I have a main editor for AProxy then AProxy has a list of BProxy 's
so in the main view i have this:

@UiField RespositorioUsuario archivos;

Then i have a sub view with something like this:

public class RespositorioUsuario extends Composite implements IsEditor<ListEditor<ArchivoProxy, RepositoryItem>> , HasRequestContext<List<ArchivoProxy>> {
   // i manage a list of RepositoryItem editors
   private class RepositorioEditorSource extends EditorSource<RepositoryItem> {

        @Override
        public RepositoryItem create(int index) {
         RepositoryItem item = new RepositoryItem();
         container.insert(item, index);
            return item;
        }
        
        @Override
        public void dispose(RepositoryItem subEditor) {
            subEditor.removeFromParent();
        }

        @Override
        public void setIndex(RepositoryItem subEditor, int index) {
         container.insert(subEditor, index);
        }

    }
 
    private ListEditor<ArchivoProxy, RepositoryItem> subeditors = ListEditor.of(new RepositorioEditorSource());
     @Override
public ListEditor<ArchivoProxy, RepositoryItem> asEditor() {
return subeditors;
      }

private AlumnoRequest request;
@Override
public void setRequestContext(RequestContext ctx) {
request = (AlumnoRequest) ctx;
}
}

Then the BProxy editor is RepositoryItem

public class RepositoryItem extends Composite implements Editor<ArchivoProxy> {
  // iam the editor of BProxy
}


So finally i want to add one Item the the list with something like this:

ArchivoProxy a = request.create(ArchivoProxy.class);
subeditors.getList().add(a);


But i cant, and dont know why... i got a NullPointerException.


Caused by: java.lang.NullPointerException: null
    at x.y.z.client.Alumnos.Editor.RespositorioUsuario$1.onChange(RespositorioUsuario.java:160)
    at com.google.gwt.event.dom.client.ChangeEvent.dispatch(ChangeEvent.java:54)
    at com.google.gwt.event.dom.client.ChangeEvent.dispatch(ChangeEvent.java:1)
    at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
    at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
    at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
    at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)

etc ....

So the getList() is returning nulll



Why?


Any help would be apreciated.

Thank you.


Daniel Mauricio Patino León

unread,
Apr 9, 2012, 4:31:01 PM4/9/12
to google-we...@googlegroups.com
My bad. 

Of course i need to initialize the ArrayList on the main Proxy when create a new one. So proxy.setArchivos(new ArrayList<ArchivoProxy>());
solved this issue.

Great GWT.



--
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/-/Y4W-kzI_qxUJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
ISC. Daniel Mauricio Patiño León.
Liondev S.A. de C.V.



Reply all
Reply to author
Forward
0 new messages