this sounds really good, but I am totally new to this cellview technique
and I need more precise hints at the moment:
- "implement a custom cell":
from which class should it be derived? AbstractCell?
As you cell does no editing, AbstractCell is the way to go.
- "that simply decides":
where and how can I implement this decision?
Its implemented in the cell's render method. Inside the cell you have access to the row value and your row value will probably have methods like isEditable(), isDeletable(), etc. If it don't, you could provide a class to the cell that knows this information. With that information you can build up the HTML render string using SafeHtmlTemplates/SafeHtmlUtils.
- "if the row is editable add an edit link/button"
I already tried exactly this by adding a Panel of Anchor objects as SafeHtml,
but the click handler is not triggered.
I assume that the connection to the click handler gets lost when putting Panel.toString() into the SafeHtml
Yes. You have only appended the HTML code of your widgets but events will be lost that way. Widget events only work inside a Widget hierarchy or when the widget provides a wrap(Element e) method like Button.wrap(buttonElement).
Cell widget events work a bit different. For example if you have a cell that needs click events, the whole CellTable will consume native browser click events. Once a click happens the CellTable figures out which column/row is clicked and then calls the onBrowserEvent() method of the cell with that information. There is only one cell instance per column that is responsible to render all possible rows and to handle all events in that column for all rows. So it needs that context information to do its job.
- "in its event method you can figure out which link/button has been clicked"
How this is to be done should depend on how the links are created.
While rendering your cell you would add custom attributes to your buttons/links that you can later identify when an event has occured. Something like <div data-action="edit">Edit</div> or <a href="javascript:;" data-action="delete">Delete</a>. You can then read the custom attribute to figure out which action to execute and you also know the column and row value. Should be everything you need.
Hope this helps. If you still need a skeleton implementation let me know.
-- J.