Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT 2.1 UiBinder SimplePager requires location attribute

Tags:

gwt

gwt2

uibinder

What can be provided to the location attribute of a

<c:SimplePager ui:field='pager' location='HERE' /> 

I tryed CENTER, but it didnt work, I see in the expense sample app that they dont have a location attribute but instead set it on the creation of it in the UiBinder. But I cant do that since its a required attribute. What to do?

like image 486
rapadura Avatar asked Nov 17 '10 13:11

rapadura


2 Answers

You must provide SimplePager.TextLocation, which can be CENTER, LEFT or RIGHT.

<c:SimplePager ui:field='pager' location='CENTER'/>
like image 155
Peter Knego Avatar answered Sep 18 '22 15:09

Peter Knego


The only solution I see at the moment is working with @UiField(provided = true). Not sure if that is of any help but check out the small example below anyway.

The ui.xml:

<!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">
    <ui:style>

    </ui:style>
    <g:HTMLPanel>
        <c:CellList ui:field="list" />
        <c:SimplePager ui:field="pager" />
        <g:Button ui:field="more" text="addMore" />
    </g:HTMLPanel>
</ui:UiBinder>

and the widget:

public class TestView extends Composite {

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

    interface TestViewUiBinder extends UiBinder<Widget, TestView> {}

    @UiField(provided = true)
    CellList<String> list;
    @UiField(provided = true)
    SimplePager pager;
    @UiField
    Button more;
    private int counter = 0;
    private ListDataProvider<String> provider;

    public TestView() {
        list = new CellList<String>(new TextCell());
        pager = new SimplePager();
        initWidget(uiBinder.createAndBindUi(this));
        provider = new ListDataProvider<String>(getList());
        provider.addDataDisplay(list);
        pager.setDisplay(list);
        pager.setPageSize(5);
    }

    private LinkedList<String> getList() {
        LinkedList<String> list = new LinkedList<String>();
        list.add("1st");
        list.add("2nd");
        list.add("3rd");
        list.add("4th");
        list.add("5th");
        return list;
    }

    @UiHandler("more")
    void onMoreClick(ClickEvent event) {
        provider.getList().add(++counter + " more");
    }
}
like image 42
z00bs Avatar answered Sep 17 '22 15:09

z00bs