My guess, and it is just a guess, is that your bean is being
instantiated by the Struts2 container but it's not being injected anywhere.
Based on my almost-non-existent understanding of OGNL, the OgnlRuntime
contains a static synchronized map of Class->PropertyAccessor which you
can see being setup in OgnlRuntime.java
The static method OgnlRuntime.setPropertyAccessor(Class,
PropertyAccessor) looks like what you're after. A quick usage search
shows it's not used in Struts2 or XWrok anywhere so I think you'll have
to make a static call from you application to register your
PropertyAccessor instance yourself. That means you don't need to define
a struts2 bean at all (unless you want to access it though the container)
Personally, I think you're setting yourself up for a world of pain
creating a custom PropertyAccessor. I'd go the simplified bean & service
façade route so to ensure I'm not locked into any particular expression
language/library.
cheers,
Jeromy Evans
Tommy Becker wrote:
I have a question about using OGNL PropertyAccessors. We have an
object on the value stack that we expose to JSP pages that does not
have standard JavaBeans getter/setter methods. From what I can tell,
this leaves us 2 options. We can either call the getter methods
explicitly via OGNL method calls in the pages, or we can wrap the
object in a JavaBean-like object. The second option is unworkable in
all but the simplest of cases when you realize that the method calls
can themselves return another object that needs to be wrapped, or even
a collection of them. So we've been using method calls in the pages
(yeah I know).
Reading through the OGNL docs, it seems that what we need is a
PropertyAccessor that knows how to operate on our object. So we
implemented one, and attempted to register it by placing this in our
struts.xml:
<bean type="ognl.PropertyAccessor" name="class.we.need.access.to"
class="our.property.accessor.PropertyAccessor"/>
Unfortunately it doesn't work. Can someone tell me what we're doing
wrong, or even if what we're trying to do is possible? Thanks!
<http://www.motricity.com>
NOTICE: This e-mail message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information
of Motricity. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient,
please contact the sender by reply e-mail and destroy all copies of
the original message.
---------------------------------------------------------------------
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]