Ok, I agree. For a simple image it is the way to do it. But what, if it is some piece of html, that is generated from several attributes from the User class ?
Something like: <a href="some link">Firstname, Lastname, age </a> Or would you create an extra component for that? > --- Urspr�ngliche Nachricht --- > Von: Andreas Andreou <[EMAIL PROTECTED]> > An: Tapestry users <[email protected]> > Betreff: Re: Is that the way to do it ? > Datum: Thu, 09 Jun 2005 17:16:27 +0300 > > Erik Hatcher wrote: > > > I personally would not create this type of intermediate object just > > for the icon. I'd map the 0/1 value to an asset in the page (or > > component) where it's needed. Or perhaps in Global if its needed in > > lots of places. > > > I'd have to agree on that. Just define 2 assets in a page or component, > such as > <context-asset name="gender0" path="images/male.gif"/> > <context-asset name="gender1" path="images/female.gif"/> > and in the html use the image component with > image="ongl:assets['gender' + user.gender]" > > > > > > > Erik > > > > > > On Jun 9, 2005, at 4:07 AM, [EMAIL PROTECTED] wrote: > > > >> Hello everyone! > >> > >> My User class has a field called gender which is 0 or 1 for male or > >> female. > >> In order to display it as an Icon for "male" or "female" I am using > the > >> following approach and i wonder whether that is good practise and > >> thread-safe etc... > >> > >> My hibernate class is called HibernateUser > >> > >> I have an additional class called User which looks like that: > >> > >> > >> class User { > >> > >> private int gender; > >> private HibernateUser hibernateUser; > >> > >> public User (HibernateUser hibernateUser){ > >> this.hibernateUser=hibernateUser; > >> } > >> > >> public String getIcon(){ > >> if (gender.equals(0)){ > >> return "male.gif"; > >> } > >> else { > >> return "female.gif"; > >> } > >> > >> } > >> > >> // + setter/getter for the private variables > >> > >> } > >> > >> Is that ok ? > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
