Hi, I have exactly the same problem.. Either I misunderstood documentation or something is broken, still trying to find the way..
On Feb 2, 6:51 pm, Daniel Francisco <[email protected]> wrote: > Hi. > > I'm working on a project with GWT 2.1 and mvp4g. In a view, I'm using > a CellList backed with a ListDataProvider. If I pass a List with data > when instantiating the ListDataProvider, the CellList shows this data. > The problem is that afterthat, the CellList never gets redrawn > whenever I change the list of ListDataProvider. I don't know what I am > doing wrong or if I missing something. I have looked into the > documentation and but I can't find anything. > > Here is the code: > > The UIBinder xml file: > > <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> > <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" > xmlns:g="urn:import:com.google.gwt.user.client.ui" > xmlns:c="urn:import:com.google.gwt.user.cellview.client" > > xmlns:v="urn:import:net.universia.ferias.feriavirtual.backend.client.exhibi > tors.view"> > <ui:style> > .leftPanel { > padding: 15px 25px 15px 25px; > } > .rightPanel { > padding: 15px 25px 15px 25px; > } > .button { > margin-right: 8px; > } > .exhibitorList { > border: 1px solid black; > background-color: #EEE; > width: 250px; > height: 600px; > } > .moduleList { > } > </ui:style> > > <g:DockLayoutPanel unit="PX"> > <g:west size="300"> > <g:VerticalPanel styleName='{style.leftPanel}' > spacing="8"> > <g:Label>Expositores</g:Label> > <g:ScrollPanel > addStyleNames='{style.exhibitorList}' > width="250px" height="600px"> > <c:CellList > ui:field="exhibitorList" /> > </g:ScrollPanel> > <g:Button ui:field="editExhibitorButton" > addStyleNames='{style.button}'>Editar</g:Button> > </g:VerticalPanel> > </g:west> > <g:center> > <g:VerticalPanel styleName='{style.rightPanel}' > spacing="8"> > <g:Label>Expositor X</g:Label> > <g:FlowPanel> > <g:Button > addStyleNames='{style.button}'>Nuevo módulo</g:Button> > <g:Button > addStyleNames='{style.button}' enabled="false">Editar > módulo</g:Button> > <g:Button > addStyleNames='{style.button}' enabled="false">Eliminar > módulo</g:Button> > </g:FlowPanel> > </g:VerticalPanel> > </g:center> > </g:DockLayoutPanel> > > </ui:UiBinder> > > The View class: > > public class ExhibitorsAdminView extends Composite implements > ExhibitorsAdminPresenter.IExhibitorsAdminView { > > interface Binder extends UiBinder<Widget, ExhibitorsAdminView> {} > > private static final Binder binder = GWT.create( Binder.class ); > > private static class ExhibitorCell extends AbstractCell<Exhibitor> { > @Override > public void render(Cell.Context context, Exhibitor exhibitor, > SafeHtmlBuilder sb) { > if (exhibitor != null) { > sb.appendEscaped(exhibitor.getName()); > } > } > } > > private ListDataProvider<Exhibitor> exhibitorsDataProvider; > > private SingleSelectionModel<Exhibitor> exhibitorsSelectionModel; > > @UiField( provided = true ) > CellList<Exhibitor> exhibitorList; > > @UiField > Button editExhibitorButton; > > // @UiField(provided = true) > // CellTable<Object> moduleList = new CellTable<Object>(); > > public ExhibitorsAdminView() { > exhibitorsSelectionModel = new > SingleSelectionModel<Exhibitor>(Exhibitor.KEY_PROVIDER); > exhibitorList = new CellList<Exhibitor>(new ExhibitorCell(), > Exhibitor.KEY_PROVIDER); > exhibitorList.setSelectionModel(exhibitorsSelectionModel); > > exhibitorsDataProvider = new > ListDataProvider<Exhibitor>(getExhibitors()); > exhibitorsDataProvider.addDataDisplay(exhibitorList); > > exhibitorList.setPageSize(exhibitorsDataProvider.getList().size()); > > initWidget( binder.createAndBindUi( this ) ); > } > > public SingleSelectionModel<Exhibitor> getExhibitorsSelectionModel() > { > return exhibitorsSelectionModel; > } > > public ListDataProvider<Exhibitor> getExhibitorsDataProvider() { > return exhibitorsDataProvider; > } > > private List<Exhibitor> getExhibitors() { > List<Exhibitor> exhibitors = new ArrayList<Exhibitor>(); > for (int i = 0; i < 10; i++) { > exhibitors.add(new Exhibitor(i, "aaaaaaaaaaaaaaa")); > } > return exhibitors; > } > > public HasClickHandlers getEditExhibitorButton() { > return editExhibitorButton; > } > > } > > The presenter class: > > @Presenter(view = ExhibitorsAdminView.class) > public class ExhibitorsAdminPresenter extends > BasePresenter<ExhibitorsAdminPresenter.IExhibitorsAdminView, > ExhibitorsEventBus> { > > public interface IExhibitorsAdminView { > > SingleSelectionModel<Exhibitor> getExhibitorsSelectionModel(); > > ListDataProvider<Exhibitor> getExhibitorsDataProvider(); > > HasClickHandlers getEditExhibitorButton(); > } > > private DispatchAsync dispatch = null; > > @Inject > public ExhibitorsAdminPresenter(final DispatchAsync dispatch) { > this.dispatch = dispatch; > } > > @Override > public void bind() { > > getView().getExhibitorsSelectionModel().addSelectionChangeHandler( > new SelectionChangeEvent.Handler() { > public void > onSelectionChange(SelectionChangeEvent event) { > Exhibitor selected = > getView().getExhibitorsSelectionModel().getSelectedObject(); > if (selected != null) { > Window.alert("You > selected: " + selected.getName()); > } > } > }); > > getView().getEditExhibitorButton().addClickHandler( > new ClickHandler() { > public void onClick(ClickEvent event) > { > > } > }); > } > > public void onGoToExhibitorsAdmin() { > > } > > public void onLoadExhibitors() { > dispatch.execute(new GetExhibitors(), new > AsyncCallback<GetExhibitorsResult>() { > public void onSuccess(GetExhibitorsResult result) { > getView().getExhibitorsDataProvider().setList( > result.getExhibitors()); > > getView().getExhibitorsDataProvider().refresh(); > } > public void onFailure(Throwable caught) { > GWT.log("error executing command ", caught); > } > }); > > } > > } > > Along with this, another thing that is happening is that > Window.alert("") (inside the onSelectionChange() method) is not > working. Which could be the reason? > > Thanks. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. 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.
