Wednesday, June 29, 2011

Re: ActionCells within a CompositeCell not receiving onBrowserEvent()

Here's the link to the example code, http://pastebin.com/GbCRiZzu

If anyone has a working example of how to get ActionCells to work within a CompositeCell posting it would be much appreciated.

Thanks

On Tue, Jun 28, 2011 at 9:24 PM, ashwin.desikan@gmail.com <ashwin.desikan@gmail.com> wrote:
Are you following the exact sample? or are you using the CompositeCell in your own project?

Can you paste the code where you are associating your CompositeCell with a table or CellList

~Ashwin


On Wed, Jun 29, 2011 at 9:42 AM, Daniel Johnston <affablebloke@gmail.com> wrote:
Thanks for the help Ashwin, but I checked the import, com.google.gwt.dom.client.Element, and its correct, however the ActionCells within the CompositeCell are still not receiving the onBrowserEvent()  .



On Tue, Jun 28, 2011 at 6:58 PM, Ashwin Desikan <ashwin.desikan@gmail.com> wrote:
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.

--
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.



--
-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.

--
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.



--
-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