You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christopher Yates <CA...@co.stark.oh.us> on 2005/03/03 18:46:33 UTC
Statics in the engine
Hello,
Page 416 of TIA says a subclassed Engine object is a great place to put
common utility methods. Well, I have a date format that is a standard
for the whole application and will be used in several places. So I put
the following in an Engine object:
public static final SimpleDateFormat DATE_FORMAT = new
SimpleDateFormat("M/d/yyyy");
However, when I try to use:
ognl:@engine@DATE_FORMAT
it results in a class not found exception.
ognl:engine@DATE_FORMAT
results in malformed OGNL expression
Is what I'm trying to do possible? Any suggestions?
Even when I try public SimpleDateFormat getDateFormat() { return
DATE_FORMAT; } and ognl:engine.dateFormat I get a No Such Property
Exception. I checked the inspector and verified the engine class is set
to my engine and not BaseEngine.
Thanks.
-
Chris Yates
Stark County Information Technology
330-451-7432 x4405
Re: Statics in the engine
Posted by Paul Ferraro <pm...@columbia.edu>.
You should keep in mind that the java.text.SimpleDateFormat object is
not thread-safe and should not be used as a static field in this way.
To answer your question, you need to use the full class name of your
engine class to reference a static field via ognl.
http://www.ognl.org/2.6.7/Documentation/html/LanguageGuide/staticFields.html
Paul
Christopher Yates wrote:
>Hello,
>
>Page 416 of TIA says a subclassed Engine object is a great place to put
>common utility methods. Well, I have a date format that is a standard
>for the whole application and will be used in several places. So I put
>the following in an Engine object:
>
>public static final SimpleDateFormat DATE_FORMAT = new
>SimpleDateFormat("M/d/yyyy");
>
>However, when I try to use:
>
>ognl:@engine@DATE_FORMAT
>
>it results in a class not found exception.
>
>ognl:engine@DATE_FORMAT
>
>results in malformed OGNL expression
>
>Is what I'm trying to do possible? Any suggestions?
>
>Even when I try public SimpleDateFormat getDateFormat() { return
>DATE_FORMAT; } and ognl:engine.dateFormat I get a No Such Property
>Exception. I checked the inspector and verified the engine class is set
>to my engine and not BaseEngine.
>
>Thanks.
>
>-
>Chris Yates
>Stark County Information Technology
>330-451-7432 x4405
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Statics in the engine
Posted by Danny Mandel <dm...@tolweb.org>.
To access a static method or var you need to use the full classname syntax.
So if your engine is named com.foo.Engine you need this:
ognl:@com.foo.Engine@DATE_FORMAT
I'm using things like this throughout my app so it is definitely possible.
Danny
Christopher Yates wrote:
>Hello,
>
>Page 416 of TIA says a subclassed Engine object is a great place to put
>common utility methods. Well, I have a date format that is a standard
>for the whole application and will be used in several places. So I put
>the following in an Engine object:
>
>public static final SimpleDateFormat DATE_FORMAT = new
>SimpleDateFormat("M/d/yyyy");
>
>However, when I try to use:
>
>ognl:@engine@DATE_FORMAT
>
>it results in a class not found exception.
>
>ognl:engine@DATE_FORMAT
>
>results in malformed OGNL expression
>
>Is what I'm trying to do possible? Any suggestions?
>
>Even when I try public SimpleDateFormat getDateFormat() { return
>DATE_FORMAT; } and ognl:engine.dateFormat I get a No Such Property
>Exception. I checked the inspector and verified the engine class is set
>to my engine and not BaseEngine.
>
>Thanks.
>
>-
>Chris Yates
>Stark County Information Technology
>330-451-7432 x4405
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org