Re: Mapping Integer attribute to WOPopupButton list.
Re: Mapping Integer attribute to WOPopupButton list.
- Subject: Re: Mapping Integer attribute to WOPopupButton list.
- From: "Jerry W. Walker" <email@hidden>
- Date: Sun, 6 Aug 2006 21:40:23 -0400
Hi, Quinton,
I'm sorry, I didn't mean to be patronizing and truly misunderstood
your question. Now that I understand it... what Anjo said. :-)
Regards,
Jerry
On Aug 6, 2006, at 7:23 PM, Q wrote:
On 07/08/2006, at 2:47 AM, Jerry W. Walker wrote:
Hi, Quinton,
I think this problem legitimately comes under the heading, "Model-
View-Controller" (MVC) which the makers of WebObjects (and its
predecessor, NeXT) took quite seriously.
I have noticed this.
Let's presume that an integer representation, as exists in the
database, is the legitimate form for these fields (given that even
if it is not, you probably have little control over the form and
content of a legacy database). That would be the "Model's"
representation of those fields. This makes sense, since it's much
easier to do arithmetic and numeric comparisons with integers than
with strings.
I probably should have given an example. Technically the integers
should be treated like foreign keys, except there is no table to
associate them with (legacy database design), instead the
relationship was done in the application's presentation code. So
you might have values 1-3, which actually mean 'No Email', 'Daily
Emails', 'Monthly Emails', for example. The integers themselves
have nothing to do with the actual meaning of the field when
presented to the user.
I couldn't really work out how to create this relationship in
eomodeller as a derived attribute, so I went down the path of using
userinfo. Perhaps there is a way to create this as a relationship
that I have not yet discovered.
Using strings to view that data is a concern of the "View" and
should be a concern separate from the "Model". Under the MVC
pattern, code applying to the model and code applying to the view
should not be mixed.
Understood. But when you have information missing from the model,
because it simply isn't in the database, do you try to put it in
the model and handle it with a generic component that knows how to
establish the relationship, or do you create a custom view
component for each and every case where this mapping occurs?
The rest of your reply (removed) seemed to imply that I was talking
about formatted vs. raw numerical data, which is my fault for not
being clear. Now that I have (hopefully) provided a bit more
detail, what technique should be applied?
Thanks for the help.
On Aug 6, 2006, at 11:52 AM, Q wrote:
I am currently reimplementing parts of an existing legacy web
application using WO as a learning exercise (I'm a WO newbie),
and have been trying both D2W and regular components. One issue I
have encountered with the database I am using is that it uses
quite a number of integer fields to represent properties that map
to strings when presented to the user. However this mapping is
not present in the database, only the legacy application's
interface code. (I am not able to modify the database schema)
After playing with D2W for a bit and creating a couple of custom
components that were virtually identical it occurred to me that
this mapping data doesn't really belong in a custom component,
instead it should actually be in the eomodel. So I wrote a custom
D2W component to map the integer value to the appropriate display
string using some custom keys in the attribute's userinfo
dictionary from the eomodel. This appears to be an elegant
solution, works nicely and seems to fit well with the WO way of
doing things, something I am still becoming familiar with.
Anyway, now that I have something working, I was curious how this
actually "should" be done, but a search didn't reveal anything
"out there" to actually do this using the eomodel to store the
relational mapping.
Have I not looked in the right places, or is it just that nobody
does it this way?
How does everyone else do this?
--
Seeya...Q
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
_____ / Quinton Dolan - email@hidden
__ __/ / / __/ / /
/ __ / _/ / / Gold Coast, QLD, Australia
__/ __/ __/ ____/ / - / Ph: +61 419 729 806
_______ /
_\
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
email@hidden
203 278-4085 office
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden