<s:set name="DynamicCodeType"
value="@com.whatever.myactioncl...@getcodetype(p.myInteger)'"/>
will work iff, static calls are enabled for OGNL, and "p" is a field
of the object on top of the stack, which I doubt, it should be
something like:
<s:set name="DynamicCodeType"
value="@com.whatever.myactioncl...@getcodetype(#p.myInteger)'"/>
assuming that "p" is in the stack pointing to your person object.
musachy
On Wed, Jan 28, 2009 at 11:49 AM, Ralf Fischer <[email protected]> wrote:
> On Wed, Jan 28, 2009 at 5:09 PM, Ryan Peterson <[email protected]> wrote:
>> p is a custom object, say person. So it could be person.age for example.
>>
>> I would use the stackObj.method() way, but the method I need to call is
>> external to the object on the stack.
>
> Why don't you perform this method invocation in your action? You can
> then save the result in a property of your action and expose it by a
> getter method, so in the JSP you can simply do
>
> <s:property value="myCalculatedValue" />
>
>> Basically I'm trying to pass the value of person.age into the OGNL static
>> method call to return a result based on that age.
>>
>> On Wed, Jan 28, 2009 at 8:55 AM, Wes Wannemacher <[email protected]> wrote:
>>
>>> On Wednesday 28 January 2009 10:50:27 Ryan Peterson wrote:
>>> > Hi guys, I have an object accessible using <s:property
>>> value="p.myInteger"
>>> > />, which displays an arbitrary integer.
>>> >
>>> > Is there a way to dynamically put this into an OGNL method call,
>>> something
>>> > like:
>>> >
>>> > <s:set name="DynamicCodeType"
>>> > value="@com.whatever.myactioncl...@getcodetype(p.myInteger)'"/>
>>> >
>>> > Right now I can populate @getCodeType with an integer value
>>> > @getCodeType(111) for example, which returns the expected results. But
>>> > when I use p.myInteger I can't seem to get it to resolve for the method
>>> > call.
>>> >
>>> > Thank you!
>>>
>>> What is 'p' ? Are you in an iterator or something? The @fqdn@ is for
>>> invoking
>>> static methods. Regular methods (exposed by objects on the stack) can be
>>> called pretty easily stackObj.method().
>>>
>>> -Wes
>>>
>>> --
>>>
>>> Wes Wannemacher
>>> Author - Struts 2 In Practice
>>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>>> http://www.manning.com/wannemacher
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]