You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Benjamin <be...@nur-eine-i.de> on 2002/08/14 16:55:30 UTC

object not calling method in velocity template

Hi everyone,
I'm having a real strange problem that a method is not called in one of
my templates. I subclassed VelocityViewServlet and put an object into
the context in the createContext() method in VelocityViewServlet. The
object works perfectly except that one method is not called, it returns
nothing. The method call in the template is the following:

$messages.formatDateFromSql($time)

where $time is a simple string (like "2002-03-20") or an empty String.
The code of the method formatDateFromSql() is the following:

  public String formatDateFromSql(String str) {
    if ( str != null && !str.equals("") )  {
      SimpleDateFormat df = new SimpleDateFormat(sourcePattern);
      try {
        Date date = df.parse(str);
        df.applyPattern(destPattern);
        str = df.format(date);
      } 
      catch (ParseException ex) {
        ex.printStackTrace();
      } 
    }    
    return str;
  }

You see, nothing bad. No exception occurs, and even if I just return the
provided String, without doing anything, nothing happens.

Any ideas? 

Thanks in advance

Benjamin

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>