[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Re: Tapestry Combobox
From:       Lance Java <lance.java () googlemail ! com>
Date:       2014-10-24 6:50:50
Message-ID: CAN7Z0vTbqNXomD_auYzUxBdAbkNuK66C9ASNjyzn-qEtjpB7sg () mail ! gmail ! com
[Download RAW message or body]


I'd just create a wrapper object that can point to either a db entity, or
an enum instance.

eg:

public class Wrapper {
   private MyEnum myEnum;
   private DbEntity dbEntity;

   public String getKey() {
      return myEnum != null ? myEnum.name() :
String.valueOf(dbEntity.getId());
   }

   public String getLabel() {
      return myEnum != null ? myEnum.name() : dbEntity.getLabel();
   }

   // getters and setters
}

Then you can create a list of Wrapper objects by combining MyEnum.values()
and a DbEntitiy collection from the database. Thi Wrapper list is then the
source of your select options.

Note: You'll need a suitable ValueEncoder to encode/decode.

On 22 October 2014 23:36, Sloshed Techie <sloshedtechie@gmail.com> wrote:

> Hello,
>
> Have just started with tapestry and web designing. I try to implement
> combobox
>
>   <t:select t:id="carstype"/>
>
> where carstype referring to enum.The selected value gets stored in
> database.
>  I need a solution where my combobox has the first value as database
> value and other
> values from ENUM.
>
>
> Any efficient solution for this?
>
>
>
> Thanks!
>
> Niks
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic