You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ken McWilliams <ke...@gmail.com> on 2010/11/30 20:19:56 UTC
Calling OGNL static method with date issue
In my jsp I have two dates ("today" and "expiryDate") the following
works in the JSP:
<s:date name="today" format="yyyy-MM-dd" />
<s:date name="expiryDate" format="yyyy-MM-dd" />
Now I created two static methods (In a Class called
dateUtils.DateRange):
/* Calling the following from my JSP:
*<s:property value="@dateUtils.DateRange@numTest(5)"/>
* Works just fine...
*/
public static int numTest(int num) {
return num + 5;
}
/* Calling the following from my JSP:
* <s:property value="@dateUtils.DateRange@dateTest(today)"/>
* DOES NOT WORK
*/
public static Date dateTest(Date date) {
date.setYear(1900);
return date;
}
Anyone know what's going wrong?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Calling OGNL static method with date issue
Posted by Dave Newton <da...@gmail.com>.
What doesn't work? Anything in the logs?
Dave
On Tue, Nov 30, 2010 at 2:19 PM, Ken McWilliams <ke...@gmail.com>wrote:
> In my jsp I have two dates ("today" and "expiryDate") the following
> works in the JSP:
> <s:date name="today" format="yyyy-MM-dd" />
> <s:date name="expiryDate" format="yyyy-MM-dd" />
>
> Now I created two static methods (In a Class called
> dateUtils.DateRange):
> /* Calling the following from my JSP:
> *<s:property value="@dateUtils.DateRange@numTest(5)"/>
> * Works just fine...
> */
> public static int numTest(int num) {
> return num + 5;
> }
>
> /* Calling the following from my JSP:
> * <s:property value="@dateUtils.DateRange@dateTest(today)"/>
> * DOES NOT WORK
> */
> public static Date dateTest(Date date) {
> date.setYear(1900);
> return date;
> }
>
> Anyone know what's going wrong?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Calling OGNL static method with date issue
Posted by Zoran Avtarovski <zo...@sparecreative.com>.
I have a feeling you have to use <s:property
value="@dateUtils.DateRange@dateTest(#today)"/> is set with a <s:date> tag
Or
<s:property value="@dateUtils.DateRange@dateTest(#attr.today)"/> if set
with a <c:set> tag.
The other option, which I know works, is to expose a method on your action
which you can then access via OGNL.
Z.
On 1/12/10 6:19 AM, "Ken McWilliams" <ke...@gmail.com> wrote:
>In my jsp I have two dates ("today" and "expiryDate") the following
>works in the JSP:
> <s:date name="today" format="yyyy-MM-dd" />
> <s:date name="expiryDate" format="yyyy-MM-dd" />
>
>Now I created two static methods (In a Class called
>dateUtils.DateRange):
>/* Calling the following from my JSP:
>*<s:property value="@dateUtils.DateRange@numTest(5)"/>
>* Works just fine...
>*/
>public static int numTest(int num) {
> return num + 5;
>}
>
>/* Calling the following from my JSP:
>* <s:property value="@dateUtils.DateRange@dateTest(today)"/>
>* DOES NOT WORK
>*/
>public static Date dateTest(Date date) {
> date.setYear(1900);
> return date;
>}
>
>Anyone know what's going wrong?
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org