On Thu, May 1, 2008 at 5:21 PM, Jeromy Evans
<[EMAIL PROTECTED]> wrote:
>
> I have a solution, but first...
> OGNL only provides access to static fields and static methods.  It cannot
> reference a static class, nor even an inner static class.
>
> http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/apa.html

Strange... because I succeeded in reading Enum values from an inner
enum class, like:

public interface MyInterface {
  enum MyEnum {
    MY_ENUM_VALUE;
  }
}

Using
  <s:property value="@[EMAIL PROTECTED]"
/>
prints:
  MY_ENUM_VALUE
(value returned by the .toString() from the Enum class)

Note: it might be dumb to do this, BUT if you use a specific Struts2
(or XWork?) converter to "translate" your enum value into something
different (e.g. introducing a label or something similar that would
returns "My Enum Value" in our example) then it's useful when not only
dealing with the Enum name (i.e. here MY_ENUM_VALUE).

I also succeeded using
  <s:property value="@[EMAIL PROTECTED]" />
that prints:
  2.718281828459045

But strangely, some:
  <s:property value="@[EMAIL PROTECTED]"
/>
does not work... why?!

... all this with Struts 2.0.11.1


> However, there is a bearable solution / hack:
>
> 1. In your Constants *class*, create a public static singleton instance of
> itself.  Lets call it C.  (Remember, OGNL can reference static fields)
> public static final Constants C = new Constants();
>
> 2. [...]

And what if, as from my above explained example, you have an
*interface*, not a class...?

Maxx

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to