(Or struts.xml, the preferred mechanism AFAIK). On Thursday, July 21, 2011, Jason Pyeron <jpye...@pdinc.us> wrote: >> -----Original Message----- >> From: Asleson, Ryan >> Sent: Thursday, July 21, 2011 8:37 >> To: user@struts.apache.org >> Subject: [struts-user] OGNL Problems During Struts2 Upgrade >> >> >> Hello, >> >> We are attempting to upgrade our application from Struts2 >> version 2.0.11.2 to the current version, 2.2.3. As part of >> the upgrade, OGNL was upgraded from version 2.7.3 to version 3.0.1. > > Not sure about the 2.0 upgrade path, will defer to someone else. > >> >> Our JSPs make use of OGNL to call static methods on classes >> to help with formatting. Here's an example: >> >> <s:property >> value="@com.example.DateUtils@toDate(promotion.startDate)" /> >> > > Can you check you struts.properties for: > > struts.ognl.allowStaticMethodAccess=true > >> The DateUtils class has a static toDate method that takes in >> the passed in promotion.startDate object (which is likely a >> java.sql.Date) and converts it to a java.util.Date. It does >> that so that s:property can properly and uniformly format the >> date for display. >> >> This had worked before the upgrade from 2.0.11.2 to 2.2.3. >> After the upgrade, it no longer works and the s:property tag >> doesn't output anything. I put some logging statements in >> the toDate method and it looks like the toDate method is >> never being called in the first place. >> >> One thing to note is that the DateUtils has two overloaded >> static toDate methods: one that takes a String, and the >> other that takes a Date (or one of its subclasses). This >> doesn't seem to make any difference as I've tried changing >> the method name (and the corresponding OGNL expression) and >> it still failed to work. >> >> On this page: >> >> http://struts.apache.org/2.2.3/docs/version-notes-211.html >> >> I see this note in the "Backward compatibility issues with >> previous versions" section: >> >> OGNL method calls like "text(key)" now invoke "text(String)" >> instead of "getText(String)". This affects method calls only, >> not properties. Some OGNL expressions may need to be updated. >> >> I'm wondering if this is what is affecting me? If so, how do >> I update the OGNL expression so that it works? I've tried a >> few things like adding #attr. or simply # to the front of >> "promotion.startDate" but that didn't seem to work. > > -- > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > - - > - Jason Pyeron PD Inc. http://www.pdinc.us - > - Principal Consultant 10 West 24th Street #100 - > - +1 (443) 269-1555 x333 Baltimore, Maryland 21218 - > - - > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > This message is copyright PD Inc, subject to license 20080407P00. > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org