In GWT project CellTable created with using AsyncDataProvider, isn't showed

131 views Asked by At

My problem is that I have just created a cellTable but it doesn't work because I see this on my broswerthe red border is of the FlowPanel that contains the table that has a black border, on side there is the GWT.log

The red border is of the FlowPanel that contains the table that has a black border, on side there is the GWT.log

Now I've tried everything but I don't know why, maybe it doesn't load the table for something reason. However I'm sure that dataProvider works beacause, as tou can see, the log show that data 'Carrello' are load on the column of my table 'carrello'. Here the code of table:

public class ShopTable extends CellTable {
private CellTable<Carrello> carrello;

private Column<Carrello, String> columnTitolo;
private Column<Carrello, String> columnTipoSupporto;

private AsyncDataProviderCarrello dataProvider;

private String COLUMN_NAME_TITOLO="Titolo film";
private String COLUMN_NAME_SUPPORTO="Tipo";

public ShopTable(){
    carrello=new CellTable<>();
    createTable();

    createWithAsyncDataProvider();
    GWT.log("Column example: "+carrello.getColumn(0).toString());
}

private void createTable(){
    columnTitolo=buildColumnTitolo();
    columnTipoSupporto=buildColumnTipoSupporto();

    // NEED TO ADD HEADER (and FOOTER MAYBE)
    carrello.addColumn(columnTitolo, "Titolo Film");
    carrello.addColumn(columnTipoSupporto, "Tipo");
}

private Column<Carrello, String> buildColumnTitolo(){
    columnTitolo=new Column<Carrello, String>(new EditTextCell()) {

        @Override
        public String getValue(Carrello object) {
            GWT.log("aggiungo a carrelloTable: "+object);
            return object.getTitolo();
        }
    };
    columnTitolo.setDataStoreName(COLUMN_NAME_TITOLO);

    return columnTitolo;
}
private Column<Carrello, String> buildColumnTipoSupporto(){
    columnTipoSupporto=new Column<Carrello, String>(new EditTextCell()) {

        @Override
        public String getValue(Carrello object) {
            GWT.log("aggiungo a carrelloTable: "+object);
            return object.getTipoSupporto().toString();
        }
    };
    columnTipoSupporto.setDataStoreName(COLUMN_NAME_TITOLO);

    return columnTipoSupporto;
}
private void createWithAsyncDataProvider(){
    dataProvider=new AsyncDataProviderCarrello();
    dataProvider.addDataDisplay(carrello);
    dataProvider.updateRowCount(10, false);
    //.. SORTING METHOD NEED TO ADD

}    

}
Here the code of Widget UIBinder that use the ShopTable

public class CarrelloPage extends Composite {

private static CarrelloPageUiBinder uiBinder = GWT.create(CarrelloPageUiBinder.class);

interface CarrelloPageUiBinder extends UiBinder<Widget, CarrelloPage> {
}

interface MyStyle extends CssResource{
    String carrelloTable();
}

@UiField MyStyle style;

@UiField FlowPanel spazio_carrello;

/**
 * necessario per dimensionare ad hoc per
 * il pannello
 */

private ShopTable carrello;

private void resizeWidget(){
    setWidth("100%");
    setHeight(Window.getClientHeight() + "px");
}

public CarrelloPage() {
    carrello=new ShopTable();
    initWidget(uiBinder.createAndBindUi(this));
    carrello.setStyleName(style.carrelloTable());
    spazio_carrello.add(carrello);
    resizeWidget();
    Window.addResizeHandler(resizeHandler);

}
private ResizeHandler resizeHandler = new ResizeHandler()
{
    public void onResize (ResizeEvent event)
    {
        setWidgetToMaxWidthAndHeight();
    }
};

private void setWidgetToMaxWidthAndHeight ()
{
    setWidth("100%");
    setHeight(Window.getClientHeight() + "px");

}
}

Thanks for attention!

1

There are 1 answers

1
Andrei Volgin On BEST ANSWER

Your CellTable has a height of zero. This is why you don't see it.

You either have to set height of your CellTable in code, or you should add it to a widget that implements ProvidesResize interface, like a LayoutPanel.