On Sunday, April 3, 2011 5:52:41 AM UTC+2, tomInNewEngland wrote:
>
> Hi All:
>
> I have a CellTree and I want to use two different cells for the leaf
> and branch nodes. The leaf nodes are all to have a checkbox and the
> brances are not. Leaves and branches appear on the same levels.
>
> I constructed a CompositeCell out of a CheckboxCell and a homegrown
> cell (based on AbstractCell<T>), and I put a test in the
> CompositeCell.render() method, that looked something like this:
>
> if (cell instanceof CheckboxCell) {
> if (value.isLeaf()) {
> cell.render(context, hasCell.getValue(value), sb);
> }
> }
>
> With this code, the checkbox cell wasn't rendered at all for the
> branch nodes. This appeared to work at first, but selecting a branch
> node would give me an error that seemed to be at the Javascript
> level. It read: "(Typeerror) elem is null". None of my code was
> identified in the stack trace, so I don't get what was wrong.
>
IIRC, CompositeCell assumes all of its composited cells are rendered, so it
assumes it has as many child nodes as composited cells.
> Can someone suggest what that error might have meant, or better,
> suggest the right way to go about designing a cell that's different
> for leaf and branch nodes that might be siblings in the CellTree.
>
Maybe put the logic of displaying the checkbox down to the CheckboxCell
(extend and override render() to either render the checkbox or a
SafeHtmlUtils.EMPTY_SAFE_HTML).
Either that, or make your own "CompositeCell-like" cell.
> Another question: when designing a cell to use, what is the right way
> to test the values that will be displayed in that cell? Besides
> including the checkbox or not, I'd like to vary the look based on
> other parameters.
I'd follow the new Appearance-based approach; this allows you to mock an
Appearance for the tests.
See
https://groups.google.com/d/topic/google-web-toolkit-contributors/SclEt5RzbvA/discussion
and http://code.google.com/p/google-web-toolkit/source/detail?r=9879
I haven't tried it though.
You could also, more simply, base your rendering on a SafeHtmlTemplates and
mock it for the tests, checking which template method is called, with which
arguments, depending on the value.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.