On Jun 9, 2005, at 9:02 AM, [EMAIL PROTECTED] wrote:
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?
It all depends on how frequently something like this is used.
Pragmatically, if it's only on one page, I'd either do it purely in
the template, an OGNL expression, or a simple Java getter. If it is
used on a couple of pages, I might make a Global method that took a
User object and formatted the name. If it was pervasive, a custom
component would be a wise choice.
One size does not fit all. Start simple and only for the case(s) you
need it for, and refactor later when the number of cases grows.
Erik
--- 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: tapestry-user-
[EMAIL PROTECTED]
For additional commands, e-mail: tapestry-user-
[EMAIL PROTECTED]
--------------------------------------------------------------------
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: tapestry-user-
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: tapestry-user-
[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]