私は少しGWTのnoobだと私はこの1つの正しい方向に微妙に感謝したいと思います。
GWT 2.4の使用
CellTableを追加するEntryPointクラスのイベントをリッスンする方法を理解できません。 CellTableにはカスタムのAbstractCellがあり、ハイパーリンクで文字列をレンダリングします。セルはクリックイベントを処理します。
EntryPointクラスがイベントを処理して、何らかのアクション(CellTableを非表示にしたり、他のウィジェットを表示するなど)ができるようにするにはどうすればよいですか?
私は正常にセルとCellTableのイベントで動作することができますが、親ウィジェット(それを処理するEntryPointクラス)を取得する方法を見つけることができません。
EntryPointクラス:
public class Tags_GWT implements EntryPoint {
private final TagGwtServiceAsync tagService = GWT.create(TagGwtService.class);
final TagCellTable tagCellTable = new TagCellTable();
public void onModuleLoad() {
RootPanel.get("tagCellTable").add(tagCellTable);
//load the table with data
tagService.getTagsAsList(new AsyncCallback>() {
public void onFailure(Throwable caught) {
GWT.log("Error loading data");
}
public void onSuccess(List tags) {
tagCellTable.setInput(tags);
}
});
CellTableクラス:
public class TagCellTable extends CellTable{
code removed for simplicity
// Add a field updater to be notified when the user enters a new name.
nameColumn.setFieldUpdater(new FieldUpdater() {
@Override
public void update(int index, TagDto object, String value) {
//Inform the user of the change.
Window.alert("TagCellTable.update is executing for: '" + value + "'");
}
});
AbstractCellクラス:
public class LinkCell extends AbstractCell{
code omitted for simplicity
@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater valueUpdater) {
super.onBrowserEvent(context, parent, value, event, valueUpdater);
if ("click".equals(event.getType())) {
//Ignore clicks that occur outside of the outermost element.
EventTarget eventTarget = event.getEventTarget();
if (parent.getFirstChildElement().isOrHasChild(Element.as(eventTarget))) {
doAction(value, valueUpdater);
}
}
}
@Override
protected void onEnterKeyDown(Context context, Element parent, String value, NativeEvent event, ValueUpdater valueUpdater) {
doAction(value, valueUpdater);
}
private void doAction(String value, ValueUpdater valueUpdater) {
Window.alert("LinkCell.doAction is executing for: ' " + value + "'");
if (valueUpdater != null) {
valueUpdater.update(value);
}
}