Hello,

Thanks. I had  a look before it. Apparently, I can make it work with a
simple Enum.
Hope I didn't overlook but it doesn't talk about the scenario I'm talking
about.

Thanks!
Niks


On Thu, Oct 23, 2014 at 8:23 PM, George Christman <gchrist...@cardaddy.com>
wrote:

> Have you seen the following example?
>
>
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/Select.html
> On Oct 23, 2014 2:10 PM, "Sloshed Techie" <sloshedtec...@gmail.com> wrote:
>
> > Hi,
> >
> > Good Afternoon!
> >
> > Thanks. Due to some constraints for using only Enum. can you please
> > elaborate the step 1.
> >
> > It should be something like the values for select box should be loaded as
> > per the values defined in Enum but with the selected enum value( which is
> > stored in database), should be the default one for the select box.
> >
> > Thanks
> > Niks!
> >
> > On Thu, Oct 23, 2014 at 5:38 PM, George Christman <
> gchrist...@cardaddy.com
> > >
> > wrote:
> >
> > > 1. You can either put all your values in your enum and store the string
> > in
> > > the database or 2. build a simple lookup table in the database
> containing
> > > your enum values and create a relationship with your primary table. I
> > would
> > > recommend option 2. There would be no need for a value encoder then.
> > >
> > > It would look something like this.
> > >
> > > <t:select value="myObject.carType" t:model="carTypeModel"/>
> > >
> > > @PageActivationContext
> > > @Property
> > > private MyObject myObject;
> > >
> > > @Inject
> > > private SelectModelFactory selectModelFactory;
> > >
> > > public void onPrepare() {
> > >     if(myObject == null) {
> > >         myObject = new MyObject();
> > >     }
> > > }
> > >
> > > public void onSuccess() {
> > >     //save car object.
> > > }
> > >
> > > public SelectModel getCarTypeModel() {
> > >     List<CarType> carTypes = your cartype query.
> > >     return selectModelFactory.create(carTypes , "name");
> > > }
> > >
> > > @Entity
> > > public class CarType {
> > >
> > >     private String name;
> > >
> > > }
> > >
> > >
> > > On Thu, Oct 23, 2014 at 6:52 AM, Thiago H de Paula Figueiredo <
> > > thiag...@gmail.com> wrote:
> > >
> > > > On Thu, 23 Oct 2014 05:05:00 -0200, Chris Poulsen <
> > > mailingl...@nesluop.dk>
> > > > wrote:
> > > >
> > > >  I don't know what you are trying to achieve, but you can always
> > provide
> > > >> your own select model, if you need something more flexible than what
> > the
> > > >> standard coercions provide. (if that was the question?)
> > > >>
> > > >
> > > > That's correct, but I guess a ValueEncoder implementation will be
> > needed
> > > > too. Either way, mixing different object classes in a Select doesn't
> > > sound
> > > > right . . .
> > > >
> > > > --
> > > > Thiago H. de Paula Figueiredo
> > > > Tapestry, Java and Hibernate consultant and developer
> > > > http://machina.com.br
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > > > For additional commands, e-mail: users-h...@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > George Christman
> > > www.CarDaddy.com
> > > P.O. Box 735
> > > Johnstown, New York
> > >
> >
>

Reply via email to