Tuesday, June 28, 2011

Re: ActionCells within a CompositeCell not receiving onBrowserEvent()

Daniel,

Check your import statement for the Element class. Thus should be using the .dom.Element package and not .client

Most probably that would be the issue for onbrowserEvent not getting invoked

Thanks
Ashwin

Sent from my iPhone

On Jun 28, 2011, at 10:46 PM, Daniel Johnston <affablebloke@gmail.com> wrote:

The ActionCell's onBrowserEvent() methods are not called.  Is there something I need to override in the CompositeCell or ConsumedEvents to make this work?

Below my example code, based on the Sample http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTree  ....


// Construct a composite cell for actions

List<HasCell<Item, ?>> hasCells = new ArrayList<HasCell<Item, ?>>();

hasCells.add(new HasCell<Item, Item>() {


private ActionCell<Item> cell = new ActionCell<Item>(

SafeHtmlUtils

.fromTrustedString(Utils.makeImage(deleteIcon)),

new ActionCell.Delegate<Item>() {


@Override

public void execute(Item item) {

listener.onDeleteClicked(item);


}

});


public Cell<Item> getCell() {

return cell;

}


public FieldUpdater<Item, Item> getFieldUpdater() {

return null;

}


public Item getValue(Item item) {

return item;

}

});


hasCells.add(new HasCell<Item, Item>() {


private ActionCell<Item> cell = new ActionCell<Item>(

SafeHtmlUtils.fromTrustedString(Utils.makeImage(editIcon)),

new ActionCell.Delegate<Item>() {


@Override

public void execute(Item item) {

listener.onEditClicked(item);


}

});


public Cell<Item> getCell() {

return cell;

}


public FieldUpdater<Item, Item> getFieldUpdater() {

return null;

}


public Item getValue(Item item) {

return item;

}

});


CompositeCell<Item> actionsCell = new CompositeCell<Item>(

hasCells) {

@Override

public void render(Context context, Item value,

SafeHtmlBuilder sb) {

sb.appendHtmlConstant("<table><tbody><tr>");

super.render(context, value, sb);

sb.appendHtmlConstant("</tr></tbody></table>");

}


@Override

protected Element getContainerElement(Element parent) {

// Return the first TR element in the table.

return parent.getFirstChildElement().getFirstChildElement()

.getFirstChildElement();

}


@Override

protected <X> void render(Context context, Item value,

SafeHtmlBuilder sb, HasCell<Item, X> hasCell) {

Cell<X> cell = hasCell.getCell();

sb.appendHtmlConstant("<td>");

cell.render(context, hasCell.getValue(value), sb);

sb.appendHtmlConstant("</td>");

}

};



Thanks in advance

---
-Daniel Johnston

--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment