------------------------------
Message: 2
Date: Thu, 7 Jun 2007 10:36:27 -0400
From: Mike Schrag <email@hidden>
Subject: Re: Type casting in WOComponents
To: WebObjects Dev Apple <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
"user.phone" is just like performing each of those method calls using
Java reflection -- It's "type independent". Fundamentally this is an
issue of your model design. If Administrator extends User (as an
aside, this is generally not a good design style -- Administrator is
a role of a user, not a subtype of a user ... meaning, you might
eventually want to make a user NOT an administrator, but if it's
typed as such, you're stuck) and user has the method "public String
phone()" or "public String getPhone()", then Administrator does
also. So binding value = user.phone where user is an Administrator
OR a User will always work, because that method is inherited. What
EXACTLY is the error you are getting? I suspect it's not the problem
you think it is.
ms
------------------------------
Message: 3
Date: Thu, 7 Jun 2007 10:39:49 -0400
From: Mike Schrag <email@hidden>
Subject: Re: Type casting in WOComponents
To: WebObjects Dev Apple <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
It's "type independent"
This is not a good choice of words -- You obviously can only call a
method on an object whose class HAS that method, but rather I mean
it's not statically bound to the method call like if you wrote this
string of method calls in code, so as long as each object in the
keypath has a method with that name, it doesn't require static typing.
ms
------------------------------
Message: 6
Date: Thu, 7 Jun 2007 09:51:58 -0600
From: Guido Neitzer <email@hidden>
Subject: Re: Type casting in WOComponents
To: Aaron Thompson <email@hidden>
Cc: WebObjects Dev Apple <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Na, if you have an EOGenericRecord (and all your objects might be
subclasses of that), you can just type "user.phone" it uses it. If
you don't have a phone attribute, you might want to surround that
part with a conditional that checks against a boolean on the EO like
<wo:if condition="user.isAdministrator">
<wo:textfield value="phone" />
</wo:if>
Or, you could have an edit page, that is generic in the way, that it
assumes it has an EOGenericRecord, has save, cancel and whatever
methods are generic and then create subclass and only re-implement
the HTML. Or use D2W ... ;-) okay, just kidding.
Otherwise, as Chuck kinda pointed out, it might be easiest to
create separate edit pages and not fight it.
Maybe yes. We have some generic pages (or components) for editing and
listing objects, and subclass from them for specific pages and
behaviour.
cug
------------------------------
Message: 7
Date: Thu, 7 Jun 2007 09:58:52 -0600
From: Guido Neitzer <email@hidden>
Subject: Re: Type casting in WOComponents
To: Mike Schrag <email@hidden>, WebObjects Dev Apple
<email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
On 07.06.2007, at 08:39, Mike Schrag wrote:
This is not a good choice of words -- You obviously can only call a
method on an object whose class HAS that method,
But isn't that just using KVC and a thing he could (not that he
should) is overriding "handleQueryWithUnboundKey" and return null in
cases where he knows the circumstances (like checking the keys and
not throwing the exception for some of the keys). But that is the
worst solution from my perspective. He better fixes the design as you
suggested (at least for the user / admin thing).
cug
------------------------------
Message: 8
Date: Thu, 7 Jun 2007 12:03:52 -0400
From: Mike Schrag <email@hidden>
Subject: Re: Type casting in WOComponents
To: WebObjects Dev Apple <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Yes, definitely, but given his original problem description, just
using regular KVC should be a totally straightforward thing to do and
that it isn't working implies a design problem that is probably
better solved more directly.
ms
On Jun 7, 2007, at 11:58 AM, Guido Neitzer wrote:
On 07.06.2007, at 08:39, Mike Schrag wrote:
This is not a good choice of words -- You obviously can only call
a method on an object whose class HAS that method,
But isn't that just using KVC and a thing he could (not that he
should) is overriding "handleQueryWithUnboundKey" and return null
in cases where he knows the circumstances (like checking the keys
and not throwing the exception for some of the keys). But that is
the worst solution from my perspective. He better fixes the design
as you suggested (at least for the user / admin thing).
cug
------------------------------
Message: 9
Date: Thu, 7 Jun 2007 10:06:55 -0600
From: Guido Neitzer <email@hidden>
Subject: Re: Type casting in WOComponents
To: Mike Schrag <email@hidden>
Cc: WebObjects Dev Apple <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
On 07.06.2007, at 10:03, Mike Schrag wrote:
Yes, definitely, but given his original problem description, just
using regular KVC should be a totally straightforward thing to do
and that it isn't working implies a design problem that is probably
better solved more directly.
Yupp. +1 as often ... ;-)
cug