That's supposed to work. Jarrod, can you get this into the issue tracker?

On Thu, Apr 29, 2010 at 10:04 AM, jarrod <[email protected]> wrote:

> Here is the @UiHandler method in question:
>
>    @UiHandler("table")
>    protected void onTableEvent(TableEvent<Publisher> event) {
>        int row = event.getRow();
>        int col = event.getColumn();
>
>        Publisher p = this.data.get(row);
>        switch (col) {
>        case 4:
>            this.presenter.onEdit(p);
>            break;
>        default:
>            this.presenter.onShow(p);
>        }
>    }
>
> When instantiating the class containing this method, I get the
> aforementioned error.
>
>
>
> On Apr 29, 1:03 pm, jarrod <[email protected]> wrote:
> > I have created my own Widget, a TableWidget. It fires a custom event,
> > TableEvent. I can't seem to get UiBinder, however, to play nice with
> > @UiHandler methods for TableEvents. Here is some code:
> >
> > public class TableWidget<T> extends ResizeComposite implements
> >         HasTableHandlers<T> {
> >
> >     private List<Column<T>> columns = Collections.emptyList();
> >
> >     private Grid grid;
> >
> >     public TableWidget(List<Column<T>> columns) {
> >         this.columns = columns;
> >         this.grid = new Grid();
> >         this.grid.addClickHandler(new ClickHandler() {
> >
> >             @Override
> >             public void onClick(ClickEvent event) {
> >                 Cell cell =
> > TableWidget.this.grid.getCellForEvent(event);
> >                 int row = cell.getRowIndex() - 1;
> >                 int col = cell.getCellIndex();
> >                 Column<T> definition =
> > TableWidget.this.columns.get(col);
> >                 fireEvent(new TableEvent<T>(row, col, definition));
> >
> >             }
> >         });
> >         clear();
> >         initWidget(this.grid);
> >     }
> >
> >     @Override
> >     public HandlerRegistration addTableHandler(TableHandler<T>
> > handler) {
> >         return addHandler(handler, TableEvent.TYPE);
> >     }
> >
> >     public void clear() {
> >         this.grid.clear();
> >         this.grid.resizeRows(1);
> >
> >         for (int i = 0; i < this.columns.size(); i++) {
> >             Column<T> col = this.columns.get(i);
> >             this.grid.setText(0, i, col.getHeader());
> >         }
> >     }
> >
> >     public void setData(List<T> data) {
> >         this.grid.resizeRows(data.size() + 1);
> >         for (int row = 1; row <= data.size(); row++) {
> >             T datum = data.get(row - 1);
> >
> >             for (int col = 0; col < this.columns.size(); col++) {
> >                 Column<T> column = this.columns.get(col);
> >                 this.grid.setText(row, col, column.render(datum));
> >             }
> >
> >         }
> >     }
> >
> > }
> >
> > public class TableEvent<T> extends GwtEvent<TableHandler<T>> {
> >
> >     public static Type<TableHandler<?>> TYPE;
> >
> >     static {
> >         TYPE = new Type<TableHandler<?>>();
> >     }
> >
> >     private int row;
> >
> >     private int col;
> >
> >     private Column<T> definition;
> >
> >     public TableEvent(int row, int column, Column<T> definition) {
> >         this.row = row;
> >         this.col = column;
> >         this.definition = definition;
> >     }
> >
> >     @SuppressWarnings("unchecked")
> >     @Override
> >     public Type<TableHandler<T>> getAssociatedType() {
> >         return (Type) TYPE;
> >     }
> >
> >     public int getColumn() {
> >         return this.col;
> >     }
> >
> >     public Column<T> getColumnDefinition() {
> >         return this.definition;
> >     }
> >
> >     public int getRow() {
> >         return this.row;
> >     }
> >
> >     @Override
> >     protected void dispatch(TableHandler<T> handler) {
> >         handler.onEvent(this);
> >     }
> >
> > }
> >
> > public interface TableHandler<T> extends EventHandler {
> >
> >     void onEvent(TableEvent<T> event);
> >
> > }
> >
> > public interface HasTableHandlers<T> extends HasHandlers {
> >
> >     HandlerRegistration addTableHandler(TableHandler<T> handler);
> >
> > }
> >
> > In my UI, I have something like this:
> >
> >         <g:DockLayoutPanel unit="PX">
> >                 <g:center>
> >                         <g:ScrollPanel>
> >                                 <misc:TableWidget ui:field="table" />
> >                         </g:ScrollPanel>
> >                 </g:center>
> >                 <g:south size="30">
> >                         <g:Button ui:field="create">(+) Add</g:Button>
> >                 </g:south>
> >         </g:DockLayoutPanel>
> >
> > Unfortunately, UiBinder blows up with the following error:
> > 00:00:13.805 [ERROR] Field 'table' does not have an 'addTableHandler'
> > method associated.
> >
> > Any ideas on why UiBinder can't see the 'addTableHandler' method that
> > is obviously there?
> >
> > --http://groups.google.com/group/Google-Web-Toolkit-Contributors
>
> --
> http://groups.google.com/group/Google-Web-Toolkit-Contributors
>

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to