CellTable SimplePager and and UiBinder with provided=true

1,315 views
Skip to first unread message

Geraldo Lopes

unread,
Jul 11, 2010, 10:12:35 AM7/11/10
to Google Web Toolkit
Hi,

I have a very simple UiBinder file :
<g:HTMLPanel>
Usuários
<c:CellTable ui:field="grid"></c:CellTable>
<c:SimplePager ui:field="paginador"></c:SimplePager>
</g:HTMLPanel>

CellTable and SimplePager needs to be instantiated using generics, and
SimplePager also needs a constructor parameter, so I used
@UiField(provided=true) for both at java side:

@UiField(provided=true) final CellTable<Usuario> grid;
@UiField(provided=true) final SimplePager<Usuario> paginador;

private ArrayList<Usuario> dados = new ArrayList<Usuario>();
private ListViewAdapter<Usuario> adapter = new
ListViewAdapter<Usuario>();

public Usuarios() {
inicializaDados();
grid = new CellTable<Usuario>(); // <-------------
adapter.addView(grid);
adapter.setList(dados);
paginador = new SimplePager<Usuario>(grid); // <---------

initWidget(uiBinder.createAndBindUi(this)); // <--------------

The strange behaviour is when I run this code I get:
10:50:26.196 [ERROR] [app] <c:SimplePager ui:field='paginador'>
missing required attribute(s): location view Element <c:SimplePager
ui:field='paginador'> (:13)

It seems that something is missing (view Element) at UiBinder side,
but I'm using provided=true which means I'm in control of
instantiating, and I provided the view element.

More strange is that with the same UiBinder file if I mix the
instantiations methods using provided for CellTable and @UiFactory for
SimplePager it works.

@UiField(provided=true) final CellTable<Usuario> grid;
@UiField SimplePager<Usuario> paginador; // <--- not using provided
anymore

private ArrayList<Usuario> dados = new ArrayList<Usuario>();
private ListViewAdapter<Usuario> adapter = new
ListViewAdapter<Usuario>();

public Usuarios() {
inicializaDados();
grid = new CellTable<Usuario>();
adapter.addView(grid);
adapter.setList(dados);

initWidget(uiBinder.createAndBindUi(this));
}
@UiFactory SimplePager<Usuario> criaSimplePager() {
SimplePager<Usuario> p = new SimplePager<Usuario>(grid);
return p;
}

I'm using GWT 2.1M2. From what I understand from docs
@UiField(provided=true) and @UiFactory are interchangeable, so I
wanted to use just one way for code clarity.

Can you comment on this subject.

Thanks in advance and sorry my english.

Geraldo Lopes



Gal Dolber

unread,
Jul 11, 2010, 2:09:11 PM7/11/10
to google-we...@googlegroups.com
That should work... 
I don't remember why, but I end up doing it like this:

CellTable<JsBean> table = new CellTable<JsBean>();

@UiField CrudPager<JsBean> pager;

@UiFactory CellTable<JsBean> getTable() {

        return table;

}

@UiFactory CrudPager<JsBean> getPager() {

        return new CrudPager<JsBean>(table);

}


2010/7/11 Geraldo Lopes <geraldo.ls@gmail.com>



--
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-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.




--
http://gwtupdates.blogspot.com/

Gal Dolber

unread,
Jul 11, 2010, 2:26:57 PM7/11/10
to google-we...@googlegroups.com
I just tried this:

@UiField(provided=true) CellTable<JsBean> table = new CellTable<JsBean>();

@UiField CrudPager<JsBean> pager;

@UiFactory CrudPager<JsBean> getPager() {

        return new CrudPager<JsBean>(table);

}


And still working ok!


2010/7/11 Gal Dolber <gal.d...@gmail.com>
Reply all
Reply to author
Forward
0 new messages