File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Invoking static methods on inner classes via value stack Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Invoking static methods on inner classes via value stack" Watch "Invoking static methods on inner classes via value stack" New topic

Invoking static methods on inner classes via value stack

Andy Wilson
Ranch Hand

Joined: Jun 26, 2009
Posts: 32
Struts 2 doesn't seem to allow methods on inner classes to be called via the value stack.
Say I have the following class structure:

package com.spam;

public class Outerclass {

public String outerMethod() {
return "outer";

public class InnerClass {
public String innerMethod() {
return "inner";

The if I have a jsp containing the following two tags:

<s:text name="@com.spam.Outerclass@outerMethod()" />
<s:text name="@com.spam.Outerclass.InnerClass@innerMethod()" />

The first tag will call the outerMethod and render the result "outer".
However, the second tag doesn't call the innerMethod and instead renders the
string "@com.spam.Outerclass.InnerClass@innerMethod()".

Does anyone know if it should be possible to do this and if so how?

BTW: I'm using struts 2.1.8.

David Newton

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

Personally, I didn't even know that syntax would work on non-static methods--I'm a little surprised. Aside from that, I'm not sure. You might have better luck asking on the Struts user mailing list; I'm not overly-familiar with how OGNL's static method syntax works under the covers.
Robert Nelson

Joined: Jan 04, 2012
Posts: 1
I'm sure this is too old for you to care anymore, Andy, but I just spent the better part of my day figuring this out and it must be posted *somewhere*!

Apparently, in OGNL, the @ symbol is for accessing stuff statically, and the $ is for accessing inner classes. In my case, I wanted to access an enum in one of my classes, which I did by doing:

In your case, I'm guessing this would work...

Again, I spent far too long looking for a solution. Apparently OGNL is partially undocumented. Bah!
I agree. Here's the link:
subject: Invoking static methods on inner classes via value stack
It's not a secret anymore!