You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ramanathan RV <ra...@gmail.com> on 2008/06/30 09:50:56 UTC

Struts2 - OGNL Calling static method

Hello

I wish to call a static method from the view and make the results available
to my view. I believed I would have to do something like this to achieve
that :

<s:set name="docs" scope="request"
value="@com.company.app.docs.DocumentProof@getDocOptions(product)"/>

The above piece of code indeed calls the method. But the result doesnt get
set on the variable as expected. Am I missing something here?

-- 
Thanks
Ram

Re: Struts2 - OGNL Calling static method

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Ramanathan RV wrote:
> Hello
>
> I wish to call a static method from the view and make the results available
> to my view. I believed I would have to do something like this to achieve
> that :
>
> <s:set name="docs" scope="request"
> value="@com.company.app.docs.DocumentProof@getDocOptions(product)"/>
>
> The above piece of code indeed calls the method. But the result doesnt get
> set on the variable as expected. Am I missing something here?
>
>   

Provided static method access is enabled (off by default), the line 
above will work.

It's possible that the problem is with the way you're accessing docs 
(are you using %{#docs})?

To enable static method access set the struts2 constant .
struts.ognl.allowStaticMethodAccess=true

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org