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]

Reply via email to