I've recently been playing around with radio buttons in Trinidad and I noticed 
a possibly very
useful change to the tr:selectOneRadio tag's implementation.

Currently, this tag only seems to work if select items are direct children of 
the tag, like this:

<tr:selectOneRadio ...>
   <tr:selectItem ... />
   <tr:selectItem ... />
   <tr:selectItem ... />
</tr:selectOneRadio>

This structure basically forces the radio buttons to be formatted as 
tr:selectOneRadio prescribes,
which makes it very hard to reposition the buttons.  Suppose, for example, I 
wanted to have a
table with one radio button associated with each line, like this:

+---+-----------------------------+
| o |   Line 1                    |
+---+-----------------------------+
| o |   Line 2                    |
+---+-----------------------------+
| o |   Line 3                    |
+---+-----------------------------+

Currently, the only way to handle this (that I can tell), is to create a bunch 
of separate
<tr:selectBooleanRadio ...> tags all sharing the same group.  While usable, 
this construct is not
very user friendly.  For example, it makes it hard to associate the selection 
of one of the
buttons with an enumerated type in the back-end.  

The only way I could figure to do it was to write a separate accessor method 
for each of the
buttons and then set the enumerated type when each of those accessors is 
called.  Handling a case
like this is a whole lot easier with the tr:selectOneRadio tag, which 
associates a single 'value'
with the group of buttons and allows me to assign those values to each of the 
select items.

So, here's the way that I would like it to work.  First, the markup:

<tr:selectOneRadio value="#{bean.radioSelection}">
   <trh:tableLayout>
      <trh:rowLayout>
         <tr:selectItem value="#{bean.item1}" />
         <tr:outputText value="Line 1" />
      </trh:rowLayout>
      <trh:rowLayout>
         <tr:selectItem value="#{bean.item2}" />
         <tr:outputText value="Line 2" />
      </trh:rowLayout>
      <trh:rowLayout>
         <tr:selectItem value="#{bean.item3}" />
         <tr:outputText value="Line 3" />
      </trh:rowLayout>
   </trh:tableLayout>
</tr:selectOneRadio>

While this is a simplistic example, notice that this becomes much more useful 
once you start using
some of Trinidad's fancy features (e.g., PPR or validation).  And, even though 
you can duplicate
this rendering and behavior with a bunch of tr:selectBooleanRadio tags, you 
lose the benefits of
recognizing the radio buttons as a single group.  

The implementation could even overload tr:selectOneRadio, so that it would 
behave as it does now
in the simple case (where its direct child elements are all select items), but 
handle the other
cases elegantly.  Presently, any non-'select item' children of a 
tr:selectOneRadio are simply not
rendered at all.

Anyway, just a suggestion.  I don't know enough about the inner plumbing of 
Trinidad to know how
feasible this is, but it would certainly be a sweet addition to the framework.

Thanks,

--David


       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

Reply via email to