You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Harish Krishnaswamy <hk...@comcast.net> on 2004/01/22 21:34:40 UTC

[OGNL] Static field accessor

This is an OGNL question, but there are quite a few OGNL experts here 
that I figured could help...
*****************
Hi,

What method should I use to retrieve a static field?

I have the expression @xyz.ClassName@FIELD_NAME and I tried 
Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if I run it 
as a simple test class but fails when I invoke it from within my 
Tapestry page. I am using v2.6.3.

TIA,
Harish



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


Re: [FIXED] Re: [OGNL] Static field accessor

Posted by Drew Davidson <dr...@ognl.org>.
Harish Krishnaswamy wrote:

> Ok, org.apache.tapestry.util.prop.OgnlUtils is the answer.
>
> My call now becomes ...
>
> public String getMyExpr()
> {
>   return OgnlUtils.get("@xyz.ClassName@FIELD_NAME", 
> getEngine().getResourceResolver(), this);
> }

The reason that this works is the funny way that webapps work with 
classloaders.  The traditional way to look up a class based on a name is 
Class.forName().  However, this only looks in the ClassLoader for the 
calling class (OgnlRuntime in this case), so that's not all that useful 
in a webapp environment.

OGNL has a facility for working with the problem of several classloaders 
(like we see in servlet containers that have Context class loaders, 
etc.) through the ognl.ClassResolver interface.  All class resolution in 
OGNL goes through the OgnlRuntime.classForName() method.  I presume that 
the Tapestry OgnlUtils class sets up the class resolver properly for the 
servlet container and that is why it works and your Ognl.getValue() does 
not.

- Drew

-- 
+---------------------------------+
< Drew Davidson | OGNL Technology >
<     Professional Open Source    >
+---------------------------------+
|  Email: drew@ognl.org          /
|    Web: http://www.ognl.org   /
|    Vox: (520) 531-1966       <
|    Fax: (520) 531-1965        \
| Mobile: (520) 405-2967         \
+---------------------------------+



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


[FIXED] Re: [OGNL] Static field accessor

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Ok, org.apache.tapestry.util.prop.OgnlUtils is the answer.

My call now becomes ...

public String getMyExpr()
{
   return OgnlUtils.get("@xyz.ClassName@FIELD_NAME", 
getEngine().getResourceResolver(), this);
}

-Harish

Harish Krishnaswamy wrote:

> I just can't seem to find where in the source Tapestry does this.
>
>
> Harish Krishnaswamy wrote:
>
>> Tapestry always registers the expression context class with OGNL 
>> AFAIK, so the default OGNL behavior of searching the classpath is 
>> never used.
>>
>> -Harish
>>
>> Colin Sampaleanu wrote:
>>
>>> Hmm, I'd almost have to say that OGNL is at fault here. I think it 
>>> should be using the context classloader.
>>>
>>> The question though if it is indeed due to the fact that it's not 
>>> using the context classloader, is how can it see all the other 
>>> application classes used in a non-static fashion?
>>>
>>>
>>> Harish Krishnaswamy wrote:
>>>
>>>> I ran it through the debugger and it turns out that its a class 
>>>> loading problem. I have all my jars in the Tomcat's shared/lib and 
>>>> my application class that has the static field is obviously in a 
>>>> webapp class loader space and hence OGNL cannot load it.
>>>>
>>>> So, now my question is how to register a class with OGNL for static 
>>>> field resolution instead of having OGNL search the classpath?
>>>>
>>>> -Harish
>>>>
>>>> Jamie Orchard-Hays wrote:
>>>>
>>>>> I'm stumped.
>>>>>
>>>>>
>>>>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>>>>> <hk...@comcast.net>
>>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>>> Sent: Thursday, January 22, 2004 4:03 PM
>>>>> Subject: Re: [OGNL] Static field accessor
>>>>>
>>>>>
>>>>>  
>>>>>
>>>>>> Yes, but the only difference is this will be called at the time of
>>>>>> loading the page when beans are configured. This a value to be 
>>>>>> passed to
>>>>>> my bean.
>>>>>>
>>>>>> <bean name="..." class="...">
>>>>>>    ...
>>>>>>    <set-property name="..." expression="myExpr" />
>>>>>>    ...
>>>>>> </bean>
>>>>>>
>>>>>> public String getMyExpr()
>>>>>> {
>>>>>>    // This expr actually comes from a component's meta property
>>>>>>    return Ognl.getValue("@xyz.ClassName@FIELD_NAME", null);
>>>>>> }
>>>>>>
>>>>>> -Harish
>>>>>>
>>>>>> Jamie Orchard-Hays wrote:
>>>>>>
>>>>>>  
>>>>>>
>>>>>>> That's the correct syntax. You're calling this from a java file, 
>>>>>>> not a
>>>>>>>     
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> page
>>>>>  
>>>>>
>>>>>>> file, right?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>>>>>>> <hk...@comcast.net>
>>>>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>>>>> Sent: Thursday, January 22, 2004 3:38 PM
>>>>>>> Subject: Re: [OGNL] Static field accessor
>>>>>>>
>>>>>>>
>>>>>>>  
>>>>>>>
>>>>>>>> java.lang.NullPointerException
>>>>>>>>
>>>>>>>> Stack Trace:
>>>>>>>>
>>>>>>>>   * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
>>>>>>>>   * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
>>>>>>>>   * ognl.SimpleNode.getValue(SimpleNode.java:192)
>>>>>>>>   * ognl.Ognl.getValue(Ognl.java:335)
>>>>>>>>   * ognl.Ognl.getValue(Ognl.java:415)
>>>>>>>>   * ognl.Ognl.getValue(Ognl.java:456)
>>>>>>>>   * ognl.Ognl.getValue(Ognl.java:435)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Harish Krishnaswamy wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>    
>>>>>>>>
>>>>>>>>> This is an OGNL question, but there are quite a few OGNL 
>>>>>>>>> experts here
>>>>>>>>> that I figured could help...
>>>>>>>>> *****************
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> What method should I use to retrieve a static field?
>>>>>>>>>
>>>>>>>>> I have the expression @xyz.ClassName@FIELD_NAME and I tried
>>>>>>>>> Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works 
>>>>>>>>> if I run
>>>>>>>>> it as a simple test class but fails when I invoke it from 
>>>>>>>>> within my
>>>>>>>>> Tapestry page. I am using v2.6.3.
>>>>>>>>>
>>>>>>>>> TIA,
>>>>>>>>> Harish
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: [OGNL] Static field accessor

Posted by Harish Krishnaswamy <hk...@comcast.net>.
I just can't seem to find where in the source Tapestry does this.


Harish Krishnaswamy wrote:

> Tapestry always registers the expression context class with OGNL 
> AFAIK, so the default OGNL behavior of searching the classpath is 
> never used.
>
> -Harish
>
> Colin Sampaleanu wrote:
>
>> Hmm, I'd almost have to say that OGNL is at fault here. I think it 
>> should be using the context classloader.
>>
>> The question though if it is indeed due to the fact that it's not 
>> using the context classloader, is how can it see all the other 
>> application classes used in a non-static fashion?
>>
>>
>> Harish Krishnaswamy wrote:
>>
>>> I ran it through the debugger and it turns out that its a class 
>>> loading problem. I have all my jars in the Tomcat's shared/lib and 
>>> my application class that has the static field is obviously in a 
>>> webapp class loader space and hence OGNL cannot load it.
>>>
>>> So, now my question is how to register a class with OGNL for static 
>>> field resolution instead of having OGNL search the classpath?
>>>
>>> -Harish
>>>
>>> Jamie Orchard-Hays wrote:
>>>
>>>> I'm stumped.
>>>>
>>>>
>>>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>>>> <hk...@comcast.net>
>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>> Sent: Thursday, January 22, 2004 4:03 PM
>>>> Subject: Re: [OGNL] Static field accessor
>>>>
>>>>
>>>>  
>>>>
>>>>> Yes, but the only difference is this will be called at the time of
>>>>> loading the page when beans are configured. This a value to be 
>>>>> passed to
>>>>> my bean.
>>>>>
>>>>> <bean name="..." class="...">
>>>>>    ...
>>>>>    <set-property name="..." expression="myExpr" />
>>>>>    ...
>>>>> </bean>
>>>>>
>>>>> public String getMyExpr()
>>>>> {
>>>>>    // This expr actually comes from a component's meta property
>>>>>    return Ognl.getValue("@xyz.ClassName@FIELD_NAME", null);
>>>>> }
>>>>>
>>>>> -Harish
>>>>>
>>>>> Jamie Orchard-Hays wrote:
>>>>>
>>>>>  
>>>>>
>>>>>> That's the correct syntax. You're calling this from a java file, 
>>>>>> not a
>>>>>>     
>>>>>
>>>>>
>>>>>
>>>> page
>>>>  
>>>>
>>>>>> file, right?
>>>>>>
>>>>>>
>>>>>>
>>>>>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>>>>>> <hk...@comcast.net>
>>>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>>>> Sent: Thursday, January 22, 2004 3:38 PM
>>>>>> Subject: Re: [OGNL] Static field accessor
>>>>>>
>>>>>>
>>>>>>   
>>>>>>
>>>>>>> java.lang.NullPointerException
>>>>>>>
>>>>>>> Stack Trace:
>>>>>>>
>>>>>>>   * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
>>>>>>>   * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
>>>>>>>   * ognl.SimpleNode.getValue(SimpleNode.java:192)
>>>>>>>   * ognl.Ognl.getValue(Ognl.java:335)
>>>>>>>   * ognl.Ognl.getValue(Ognl.java:415)
>>>>>>>   * ognl.Ognl.getValue(Ognl.java:456)
>>>>>>>   * ognl.Ognl.getValue(Ognl.java:435)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Harish Krishnaswamy wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>     
>>>>>>>
>>>>>>>> This is an OGNL question, but there are quite a few OGNL 
>>>>>>>> experts here
>>>>>>>> that I figured could help...
>>>>>>>> *****************
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> What method should I use to retrieve a static field?
>>>>>>>>
>>>>>>>> I have the expression @xyz.ClassName@FIELD_NAME and I tried
>>>>>>>> Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if 
>>>>>>>> I run
>>>>>>>> it as a simple test class but fails when I invoke it from 
>>>>>>>> within my
>>>>>>>> Tapestry page. I am using v2.6.3.
>>>>>>>>
>>>>>>>> TIA,
>>>>>>>> Harish
>>>>>>>
>>>>>>>
>>>>>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: [OGNL] Static field accessor

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Tapestry always registers the expression context class with OGNL AFAIK, 
so the default OGNL behavior of searching the classpath is never used.

-Harish

Colin Sampaleanu wrote:

> Hmm, I'd almost have to say that OGNL is at fault here. I think it 
> should be using the context classloader.
>
> The question though if it is indeed due to the fact that it's not 
> using the context classloader, is how can it see all the other 
> application classes used in a non-static fashion?
>
>
> Harish Krishnaswamy wrote:
>
>> I ran it through the debugger and it turns out that its a class 
>> loading problem. I have all my jars in the Tomcat's shared/lib and my 
>> application class that has the static field is obviously in a webapp 
>> class loader space and hence OGNL cannot load it.
>>
>> So, now my question is how to register a class with OGNL for static 
>> field resolution instead of having OGNL search the classpath?
>>
>> -Harish
>>
>> Jamie Orchard-Hays wrote:
>>
>>> I'm stumped.
>>>
>>>
>>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>>> <hk...@comcast.net>
>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>> Sent: Thursday, January 22, 2004 4:03 PM
>>> Subject: Re: [OGNL] Static field accessor
>>>
>>>
>>>  
>>>
>>>> Yes, but the only difference is this will be called at the time of
>>>> loading the page when beans are configured. This a value to be 
>>>> passed to
>>>> my bean.
>>>>
>>>> <bean name="..." class="...">
>>>>    ...
>>>>    <set-property name="..." expression="myExpr" />
>>>>    ...
>>>> </bean>
>>>>
>>>> public String getMyExpr()
>>>> {
>>>>    // This expr actually comes from a component's meta property
>>>>    return Ognl.getValue("@xyz.ClassName@FIELD_NAME", null);
>>>> }
>>>>
>>>> -Harish
>>>>
>>>> Jamie Orchard-Hays wrote:
>>>>
>>>>  
>>>>
>>>>> That's the correct syntax. You're calling this from a java file, 
>>>>> not a
>>>>>     
>>>>
>>>>
>>> page
>>>  
>>>
>>>>> file, right?
>>>>>
>>>>>
>>>>>
>>>>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>>>>> <hk...@comcast.net>
>>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>>> Sent: Thursday, January 22, 2004 3:38 PM
>>>>> Subject: Re: [OGNL] Static field accessor
>>>>>
>>>>>
>>>>>    
>>>>>
>>>>>> java.lang.NullPointerException
>>>>>>
>>>>>> Stack Trace:
>>>>>>
>>>>>>   * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
>>>>>>   * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
>>>>>>   * ognl.SimpleNode.getValue(SimpleNode.java:192)
>>>>>>   * ognl.Ognl.getValue(Ognl.java:335)
>>>>>>   * ognl.Ognl.getValue(Ognl.java:415)
>>>>>>   * ognl.Ognl.getValue(Ognl.java:456)
>>>>>>   * ognl.Ognl.getValue(Ognl.java:435)
>>>>>>
>>>>>>
>>>>>>
>>>>>> Harish Krishnaswamy wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>      
>>>>>>
>>>>>>> This is an OGNL question, but there are quite a few OGNL experts 
>>>>>>> here
>>>>>>> that I figured could help...
>>>>>>> *****************
>>>>>>> Hi,
>>>>>>>
>>>>>>> What method should I use to retrieve a static field?
>>>>>>>
>>>>>>> I have the expression @xyz.ClassName@FIELD_NAME and I tried
>>>>>>> Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if 
>>>>>>> I run
>>>>>>> it as a simple test class but fails when I invoke it from within my
>>>>>>> Tapestry page. I am using v2.6.3.
>>>>>>>
>>>>>>> TIA,
>>>>>>> Harish
>>>>>>
>>>>>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: [OGNL] Static field accessor

Posted by Colin Sampaleanu <co...@exis.com>.
Hmm, I'd almost have to say that OGNL is at fault here. I think it 
should be using the context classloader.

The question though if it is indeed due to the fact that it's not using 
the context classloader, is how can it see all the other application 
classes used in a non-static fashion?


Harish Krishnaswamy wrote:

> I ran it through the debugger and it turns out that its a class 
> loading problem. I have all my jars in the Tomcat's shared/lib and my 
> application class that has the static field is obviously in a webapp 
> class loader space and hence OGNL cannot load it.
>
> So, now my question is how to register a class with OGNL for static 
> field resolution instead of having OGNL search the classpath?
>
> -Harish
>
> Jamie Orchard-Hays wrote:
>
>> I'm stumped.
>>
>>
>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>> <hk...@comcast.net>
>> To: "Tapestry users" <ta...@jakarta.apache.org>
>> Sent: Thursday, January 22, 2004 4:03 PM
>> Subject: Re: [OGNL] Static field accessor
>>
>>
>>  
>>
>>> Yes, but the only difference is this will be called at the time of
>>> loading the page when beans are configured. This a value to be 
>>> passed to
>>> my bean.
>>>
>>> <bean name="..." class="...">
>>>    ...
>>>    <set-property name="..." expression="myExpr" />
>>>    ...
>>> </bean>
>>>
>>> public String getMyExpr()
>>> {
>>>    // This expr actually comes from a component's meta property
>>>    return Ognl.getValue("@xyz.ClassName@FIELD_NAME", null);
>>> }
>>>
>>> -Harish
>>>
>>> Jamie Orchard-Hays wrote:
>>>
>>>   
>>>
>>>> That's the correct syntax. You're calling this from a java file, not a
>>>>     
>>>
>> page
>>  
>>
>>>> file, right?
>>>>
>>>>
>>>>
>>>> ----- Original Message ----- From: "Harish Krishnaswamy" 
>>>> <hk...@comcast.net>
>>>> To: "Tapestry users" <ta...@jakarta.apache.org>
>>>> Sent: Thursday, January 22, 2004 3:38 PM
>>>> Subject: Re: [OGNL] Static field accessor
>>>>
>>>>
>>>>     
>>>>
>>>>> java.lang.NullPointerException
>>>>>
>>>>> Stack Trace:
>>>>>
>>>>>   * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
>>>>>   * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
>>>>>   * ognl.SimpleNode.getValue(SimpleNode.java:192)
>>>>>   * ognl.Ognl.getValue(Ognl.java:335)
>>>>>   * ognl.Ognl.getValue(Ognl.java:415)
>>>>>   * ognl.Ognl.getValue(Ognl.java:456)
>>>>>   * ognl.Ognl.getValue(Ognl.java:435)
>>>>>
>>>>>
>>>>>
>>>>> Harish Krishnaswamy wrote:
>>>>>
>>>>>
>>>>>
>>>>>       
>>>>>
>>>>>> This is an OGNL question, but there are quite a few OGNL experts 
>>>>>> here
>>>>>> that I figured could help...
>>>>>> *****************
>>>>>> Hi,
>>>>>>
>>>>>> What method should I use to retrieve a static field?
>>>>>>
>>>>>> I have the expression @xyz.ClassName@FIELD_NAME and I tried
>>>>>> Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if I 
>>>>>> run
>>>>>> it as a simple test class but fails when I invoke it from within my
>>>>>> Tapestry page. I am using v2.6.3.
>>>>>>
>>>>>> TIA,
>>>>>> Harish
>>>>>



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


Re: [OGNL] Static field accessor

Posted by Harish Krishnaswamy <hk...@comcast.net>.
I ran it through the debugger and it turns out that its a class loading 
problem. I have all my jars in the Tomcat's shared/lib and my 
application class that has the static field is obviously in a webapp 
class loader space and hence OGNL cannot load it.

So, now my question is how to register a class with OGNL for static 
field resolution instead of having OGNL search the classpath?

-Harish

Jamie Orchard-Hays wrote:

>I'm stumped.
>
>
>----- Original Message ----- 
>From: "Harish Krishnaswamy" <hk...@comcast.net>
>To: "Tapestry users" <ta...@jakarta.apache.org>
>Sent: Thursday, January 22, 2004 4:03 PM
>Subject: Re: [OGNL] Static field accessor
>
>
>  
>
>>Yes, but the only difference is this will be called at the time of
>>loading the page when beans are configured. This a value to be passed to
>>my bean.
>>
>><bean name="..." class="...">
>>    ...
>>    <set-property name="..." expression="myExpr" />
>>    ...
>></bean>
>>
>>public String getMyExpr()
>>{
>>    // This expr actually comes from a component's meta property
>>    return Ognl.getValue("@xyz.ClassName@FIELD_NAME", null);
>>}
>>
>>-Harish
>>
>>Jamie Orchard-Hays wrote:
>>
>>    
>>
>>>That's the correct syntax. You're calling this from a java file, not a
>>>      
>>>
>page
>  
>
>>>file, right?
>>>
>>>
>>>
>>>----- Original Message ----- 
>>>From: "Harish Krishnaswamy" <hk...@comcast.net>
>>>To: "Tapestry users" <ta...@jakarta.apache.org>
>>>Sent: Thursday, January 22, 2004 3:38 PM
>>>Subject: Re: [OGNL] Static field accessor
>>>
>>>
>>>      
>>>
>>>>java.lang.NullPointerException
>>>>
>>>>Stack Trace:
>>>>
>>>>   * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
>>>>   * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
>>>>   * ognl.SimpleNode.getValue(SimpleNode.java:192)
>>>>   * ognl.Ognl.getValue(Ognl.java:335)
>>>>   * ognl.Ognl.getValue(Ognl.java:415)
>>>>   * ognl.Ognl.getValue(Ognl.java:456)
>>>>   * ognl.Ognl.getValue(Ognl.java:435)
>>>>
>>>>
>>>>
>>>>Harish Krishnaswamy wrote:
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>>>This is an OGNL question, but there are quite a few OGNL experts here
>>>>>that I figured could help...
>>>>>*****************
>>>>>Hi,
>>>>>
>>>>>What method should I use to retrieve a static field?
>>>>>
>>>>>I have the expression @xyz.ClassName@FIELD_NAME and I tried
>>>>>Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if I run
>>>>>it as a simple test class but fails when I invoke it from within my
>>>>>Tapestry page. I am using v2.6.3.
>>>>>
>>>>>TIA,
>>>>>Harish
>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>


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


Re: [OGNL] Static field accessor

Posted by Jamie Orchard-Hays <ja...@dang.com>.
I'm stumped.


----- Original Message ----- 
From: "Harish Krishnaswamy" <hk...@comcast.net>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, January 22, 2004 4:03 PM
Subject: Re: [OGNL] Static field accessor


> Yes, but the only difference is this will be called at the time of
> loading the page when beans are configured. This a value to be passed to
> my bean.
>
> <bean name="..." class="...">
>     ...
>     <set-property name="..." expression="myExpr" />
>     ...
> </bean>
>
> public String getMyExpr()
> {
>     // This expr actually comes from a component's meta property
>     return Ognl.getValue("@xyz.ClassName@FIELD_NAME", null);
> }
>
> -Harish
>
> Jamie Orchard-Hays wrote:
>
> >That's the correct syntax. You're calling this from a java file, not a
page
> >file, right?
> >
> >
> >
> >----- Original Message ----- 
> >From: "Harish Krishnaswamy" <hk...@comcast.net>
> >To: "Tapestry users" <ta...@jakarta.apache.org>
> >Sent: Thursday, January 22, 2004 3:38 PM
> >Subject: Re: [OGNL] Static field accessor
> >
> >
> >>java.lang.NullPointerException
> >>
> >>Stack Trace:
> >>
> >>    * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
> >>    * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
> >>    * ognl.SimpleNode.getValue(SimpleNode.java:192)
> >>    * ognl.Ognl.getValue(Ognl.java:335)
> >>    * ognl.Ognl.getValue(Ognl.java:415)
> >>    * ognl.Ognl.getValue(Ognl.java:456)
> >>    * ognl.Ognl.getValue(Ognl.java:435)
> >>
> >>
> >>
> >>Harish Krishnaswamy wrote:
> >>
> >>
> >>
> >>>This is an OGNL question, but there are quite a few OGNL experts here
> >>>that I figured could help...
> >>>*****************
> >>>Hi,
> >>>
> >>>What method should I use to retrieve a static field?
> >>>
> >>>I have the expression @xyz.ClassName@FIELD_NAME and I tried
> >>>Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if I run
> >>>it as a simple test class but fails when I invoke it from within my
> >>>Tapestry page. I am using v2.6.3.
> >>>
> >>>TIA,
> >>>Harish
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: [OGNL] Static field accessor

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Yes, but the only difference is this will be called at the time of 
loading the page when beans are configured. This a value to be passed to 
my bean.

<bean name="..." class="...">
    ...
    <set-property name="..." expression="myExpr" />
    ...
</bean>

public String getMyExpr()
{
    // This expr actually comes from a component's meta property
    return Ognl.getValue("@xyz.ClassName@FIELD_NAME", null);
}

-Harish

Jamie Orchard-Hays wrote:

>That's the correct syntax. You're calling this from a java file, not a page
>file, right?
>
>
>
>----- Original Message ----- 
>From: "Harish Krishnaswamy" <hk...@comcast.net>
>To: "Tapestry users" <ta...@jakarta.apache.org>
>Sent: Thursday, January 22, 2004 3:38 PM
>Subject: Re: [OGNL] Static field accessor
>  
>
>>java.lang.NullPointerException
>>
>>Stack Trace:
>>
>>    * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
>>    * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
>>    * ognl.SimpleNode.getValue(SimpleNode.java:192)
>>    * ognl.Ognl.getValue(Ognl.java:335)
>>    * ognl.Ognl.getValue(Ognl.java:415)
>>    * ognl.Ognl.getValue(Ognl.java:456)
>>    * ognl.Ognl.getValue(Ognl.java:435)
>>
>>
>>
>>Harish Krishnaswamy wrote:
>>
>>    
>>
>>>This is an OGNL question, but there are quite a few OGNL experts here
>>>that I figured could help...
>>>*****************
>>>Hi,
>>>
>>>What method should I use to retrieve a static field?
>>>
>>>I have the expression @xyz.ClassName@FIELD_NAME and I tried
>>>Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if I run
>>>it as a simple test class but fails when I invoke it from within my
>>>Tapestry page. I am using v2.6.3.
>>>
>>>TIA,
>>>Harish
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>  
>


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


Re: [OGNL] Static field accessor

Posted by Jamie Orchard-Hays <ja...@dang.com>.
That's the correct syntax. You're calling this from a java file, not a page
file, right?



----- Original Message ----- 
From: "Harish Krishnaswamy" <hk...@comcast.net>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, January 22, 2004 3:38 PM
Subject: Re: [OGNL] Static field accessor
> java.lang.NullPointerException
>
> Stack Trace:
>
>     * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
>     * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
>     * ognl.SimpleNode.getValue(SimpleNode.java:192)
>     * ognl.Ognl.getValue(Ognl.java:335)
>     * ognl.Ognl.getValue(Ognl.java:415)
>     * ognl.Ognl.getValue(Ognl.java:456)
>     * ognl.Ognl.getValue(Ognl.java:435)
>
>
>
> Harish Krishnaswamy wrote:
>
> > This is an OGNL question, but there are quite a few OGNL experts here
> > that I figured could help...
> > *****************
> > Hi,
> >
> > What method should I use to retrieve a static field?
> >
> > I have the expression @xyz.ClassName@FIELD_NAME and I tried
> > Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if I run
> > it as a simple test class but fails when I invoke it from within my
> > Tapestry page. I am using v2.6.3.
> >
> > TIA,
> > Harish
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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


Re: [OGNL] Static field accessor

Posted by Harish Krishnaswamy <hk...@comcast.net>.
The partial stack trace...

java.lang.NullPointerException

Stack Trace:

    * ognl.OgnlRuntime.getStaticField(OgnlRuntime.java:988)
    * ognl.ASTStaticField.getValueBody(ASTStaticField.java:61)
    * ognl.SimpleNode.getValue(SimpleNode.java:192)
    * ognl.Ognl.getValue(Ognl.java:335)
    * ognl.Ognl.getValue(Ognl.java:415)
    * ognl.Ognl.getValue(Ognl.java:456)
    * ognl.Ognl.getValue(Ognl.java:435)



Harish Krishnaswamy wrote:

> This is an OGNL question, but there are quite a few OGNL experts here 
> that I figured could help...
> *****************
> Hi,
>
> What method should I use to retrieve a static field?
>
> I have the expression @xyz.ClassName@FIELD_NAME and I tried 
> Ognl.getValue("@xyz.ClassName@FIELD_NAME", null), this works if I run 
> it as a simple test class but fails when I invoke it from within my 
> Tapestry page. I am using v2.6.3.
>
> TIA,
> Harish
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


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