For your simple examples, I have used the concept of an object having
"lookup properties".

IE, your object defines variables.instance.name,
variables.instance.dob, etc as standard properties, then
variables.lookup.UserTypeName.  The load method for the object will
populate these properties.  (you can even use a
setStateFromQueryMemento() method to achieve this)

You need to use this very sparingly, as you run into problems with
UserTypeName being out of sync when external code is calling
user.setUserTypeID().  I'd also have setUserTypeName private and
getUserTypeName public.

Certainly not as academically correct as having proper compositions,
however it works quite well in the real world as long as you don't
abuse it.






On Dec 1, 1:55 pm, Phil Rasmussen <[email protected]> wrote:
> Hi Everyone,
>
> Just wondering what the best practices were when it comes to
> displaying friendly names of foreign key based values in an Entity
> Bean at the View layer. So lets say for example I have a User bean
> with all the standard getter/setter methods for id/name/dob/age etc,
> but I also have a UserTypeId property which is stored as an ID value
> only corresponding to the foreign key "variables.instance.usertypeid"
>
> Now i will obviously have a getter and setter for getUserTypeId and
> setUserTypeId, however at the View layer i also want to display the
> actual User Type name somewhere, and I don't like the idea of making
> additional Gateway calls just to grab a single name value? I've read
> that some people will create objects out of all reference data such as
> having a UserType object which is stored against the User directly,
> and I can then output the name by writing
> #objUser.getUserType.getName()# for example.
>
> I seem to run into this issue a lot as the bigger the Entity bean the
> more foreign key references will usually exist and somewhere at the
> View layer i need to get the user friendly name value and display it.
> Would love to hear what others are doing with regards to this?
>
> Cheers
> Phil

-- 
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en.

Reply via email to