I am attempting to make a column renderer that works like an editable textfield. Eventually, this textfield needs to save data when focus is lost, but currently I can’t even get the textfield to appear at all. Worse, I can’t even get
this simple example
to work.
I have been scouring this forum for some good examples or tips, but other than
this post
I can’t really find too much. Here is what I have attempted to do … if I did something completely stupid, please don’t hesitate to point that out.
Client Side Renderer:
import com.vaadin.client.renderers.Renderer;
import com.vaadin.client.widget.grid.RendererCellReference;
/**
* Created by dangoloborodko on 7/7/2015.
*/
public class GridEditableRenderer implements Renderer<String> {
@Override
public void render(RendererCellReference cell, String text) {
cell.getElement().setInnerText(text);
}
}
Server Side Renderer:
import com.vaadin.ui.Grid;
/**
* Created by dangoloborodko on 7/7/2015.
*/
public class GridEditableRenderer extends Grid.AbstractRenderer<String> {
public GridEditableRenderer() {
super(String.class);
}
}
Connector:
import com.vaadin.client.connectors.AbstractRendererConnector;
import com.vaadin.shared.ui.Connect;
import org.ici.weekly.ui.renderer.GridEditableRenderer;
/**
* Created by dangoloborodko on 7/7/2015.
*/
@Connect(org.ici.weekly.server_render.GridEditableRenderer.class)
public class GridEditableRendererConnector extends AbstractRendererConnector<String> {
@Override
public GridEditableRenderer getRenderer() {
return (GridEditableRenderer) super.getRenderer();
}
}
My IDE doesn’t complain about anything so far, but once I try binding the renderer to the Grid, I am having problems. I tried binding it this way:
complexGrid.getColumn("tna").setRenderer(new GridEditableRenderer());
But, it is complaining that it wants something like this:
(com.vaadin.ui.renderers.Renderer<?>)
So, first off, what am I doing wrong so far? But, more importantly, I don’t see how the renderer will be getting the data out of the model to display. It seems to me that my client side renderer needs to implement com.vaadin.ui.renderers.Renderer rather than com.vaadin.client.renderers.Renderer (note the missing ui), but if I do that than it looks nothing like the simple example shown, it instead overrides dozens of other functions that I am not sure are all that necessary.
TLDR, please help … I’m lost.