RadioCell?

570 views
Skip to first unread message

BrianV

unread,
Nov 17, 2010, 11:46:50 AM11/17/10
to Google Web Toolkit
I was hoping to put a list of radio buttons in a CellTable column but
didn't see the equivalent RadioCell class. I'm prototyping with a
SelectCell, but it really calls for a few radio buttons in a group.
What's the best magic incantation to coerce GWT's CellTable/Cell
Columns to rendering a group of radio buttons?

zixzigma

unread,
Nov 17, 2010, 5:32:22 PM11/17/10
to Google Web Toolkit
i was also curious to know if there is a Checkbox Cell ?

John LaBanca

unread,
Nov 17, 2010, 5:38:43 PM11/17/10
to google-we...@googlegroups.com
There is a CheckboxCell but there is not a RadioCell.  I think BrianV was looking for a RadioGroupCell that would show multiple radio buttons in a single cell, but that isn't implemented.

Thanks,
John LaBanca
jlab...@google.com


On Wed, Nov 17, 2010 at 5:32 PM, zixzigma <zixz...@gmail.com> wrote:
i was also curious to know if there is a Checkbox Cell ?

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


BrianV

unread,
Nov 17, 2010, 5:44:15 PM11/17/10
to Google Web Toolkit
There is - see CheckboxCell. It works fine, but it is not a collection
of radio buttons.

I did look at the GWT source for several other "Cell" objects and it
looks straightforward to create a custom "RadioCell" that implements a
single Radio button (using the CheckboxCell as a roadmap for how this
is done). However, what would be the best way to cram 3 or 4 of them
in a Cell? Is the CompositeCell the right mechanism for this? Is there
anything special that my custom "RadioCell" would need to do to be a
member of a "CompositeCell"?

Thomas Broyer

unread,
Nov 17, 2010, 7:22:12 PM11/17/10
to Google Web Toolkit


On 17 nov, 23:44, BrianV <brian.vet...@bluespace.com> wrote:
> There is - see CheckboxCell. It works fine, but it is not a collection
> of radio buttons.
>
> I did look at the GWT source for several other "Cell" objects and it
> looks straightforward to create a custom "RadioCell" that implements a
> single Radio button (using the CheckboxCell as a roadmap for how this
> is done). However, what would be the best way to cram 3 or 4 of them
> in a Cell? Is the CompositeCell the right mechanism for this? Is there
> anything special that my custom "RadioCell" would need to do to be a
> member of a "CompositeCell"?

I wouldn't use a CompositeCell (CompositeCell is more about the same
as a CellTable row but without the column-based layout).
The thing you'd have to take care of would be entering/exiting "edit
mode" (isEditing()) and focus management (i.e. resetFocus). It's easy
with the built-in cells as they only have a single focusable element
(check box, text box, select) but I suppose it could become tricky
with multiple radio buttons, to give the focus back to the appropriate
radio button in the cell.

BrianV

unread,
Nov 17, 2010, 11:44:58 PM11/17/10
to Google Web Toolkit
I took another approach but have hit a roadblock. Instead of starting
with CheckboxCell and CompositeCell, I started with the SelectionCell
figuring that it already had multiple options. Unfortunately, I
haven't figured out a way to get the "radio group" (aka "name") field
into the generated safehtml. I need a unique group per cell (for all
of the radio buttons that are created) which on the surface isn't
hard. My plan is to generate a new group name for them when "render"
is called.

The one part I'm stumped in is that I need to append some text after
the <input ..../> text. For example: <input type="radio" name"group1"
value="Goobers" /> Goobers

When I add the " Goobers" at the end, I get an exception: Content is
not allowed in trailing section. I was using a Template to generate
the SafeHTML. The template looks like the following:
@Template("<input type=\"radio\" name=\"{0}\" value=\"{1}\"/>
{1}")

I'm doing something wrong (perhaps carrying something over from the
SelectionCell I shouldn't be) but the html would seem correct. Any
ideas?

BrianV

unread,
Nov 18, 2010, 12:04:57 AM11/18/10
to Google Web Toolkit
Nevermind - I surrounded the template text with <span> </span> tags,
generated a random group name in the render method, and it all seems
to be mostly working.

Thomas Broyer

unread,
Nov 18, 2010, 6:32:15 AM11/18/10
to Google Web Toolkit
Even better would be using <label> so that when the text is clicked
the radio button is selected.
<label><input type="radio" name="{0}" value="{1}" /> {1}</label>

Andrei

unread,
Sep 12, 2012, 11:50:47 PM9/12/12
to google-we...@googlegroups.com
I think it's a bad idea from a user interface perspective. Imagine you have three radio buttons in a cell, and a many rows. Now your user is presented with dozens of radio buttons that take a lot of space. It would look very confusing. Use a regular SelectionCell - this is a UI concept that all users are familiar with. And you will save a lot of time :)

S. DG

unread,
Sep 13, 2012, 1:20:29 AM9/13/12
to google-we...@googlegroups.com
I understand your point.
Even i had a similar view when i was asked to implement this. But again for Tables where we have not more 2-3 Radio choices i guess it is fine. But I am still not clear why GWT api have not implemented this yet. People have been looking for it for quite sometime now. I started GWT-ing just a week back.
Anyways I am able to create my own RadioGroupCell now after reading through this and many other blogs and breaking my head.

Thanks to all.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages