Hi

While trying to answer your question, I came up with an example. Enjoy !!

public class RadioGroupDemo
{
   @Property
   @Persist
   private List<User> users;

   @SuppressWarnings("unused")
   @Property
   private User user;

   @SuppressWarnings("unused")
   @Property
   @Persist(PersistenceConstants.FLASH)
   private User selectedUser;

   void onActivate()
   {
      if(users == null)
      {
         users = new ArrayList<User>();
         users.add(new User("John", "New York"));
         users.add(new User("Ramesh", "India"));
      }
   }

   public ValueEncoder<User> getEncoder()
   {
      return new ValueEncoder<User>()
      {
         @Override
         public String toClient(User user)
         {
            if(user == null)
            {
               return null;
            }
            return user.getName();
         }

         @Override
         public User toValue(String clientValue)
         {
            for(User user : users)
            {
               if(user.getName().equals(clientValue))
               {
                  return user;
               }
            }
            return null;
         }

      };
   }

}

<html xmlns:t='http://tapestry.apache.org/schema/tapestry_5_1_0.xsd'
xmlns:p='tapestry:parameter'>
   <body>
      <t:if test='selectedUser'>
         You selected : ${selectedUser.name}
      </t:if>
      <form t:type='form'>
         <div t:type='radioGroup' t:value='selectedUser' encoder='encoder'>
            <div t:type='grid' source='users' t:add='select' row='user'>

               <p:selectCell>
                  <input t:type='radio' type='radio' t:value='user' />
               </p:selectCell>

            </div>
         </div>

         <input type='submit' value='submit'/>
      </form>

   </body>
</html>

Remember, your object (User here) must has proper equals/hashcode
methods for selection to work

Regards
Taha


On Mon, Jul 25, 2011 at 6:18 PM, nillehammer
<tapestry.nilleham...@winfonet.eu> wrote:
> Hi Stephan,
>
> afaik it's easy to ovveride the rendering of a single column in Grid, but
> it's hard to overide the rendering of a whole row. You could subclass Grid
> and GridRows to get the desired behavior. Anoter option could be to put your
> whole radiogroup in just one td and write a mixin that changes the markup in
> afterRender to split up the clumn into several tds.
>
> I can recall that Subclassing Grid and GridRow invloves quite an amount of
> work and the mixin might look a bit dirty. Perhaps you should refrain from
> using Grid and better implement your own component that suits your needs.
>
> Cheers nillehammer
>
> -----
> http://www.winfonet.eu
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/Using-RadioGroup-inside-a-Grid-tp4629982p4630617.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to