Re: 'translate' is bound to null

2009-11-18 Thread Inge Solvoll
Got this working by creating a translator.

I got confused because I already contributed a DateCoercer to TypeCoercions,
I thought that would be enough. I guess I don't fully understand how this
system works. I think I read a discussion somewhere about T5 containing too
many ways of translating values, though, with encoders, translators and
coercers?

Anyway, my simple solution is listed below if anyone's interested. Does
anyone have ideas on how to access component or mixin parameters in the
DateTranslator class? It would be useful to get access to a dateFormat
parameter when translating.

Appmodule.java:
public static void contributeTranslatorSource(ConfigurationTranslator
configuration) {
configuration.add(new DateTranslator());
  }



public class DateTranslator extends AbstractTranslatorDate {

  public DateTranslator()
  {
  super(date, Date.class, errors.date);
  }

  /**
   * Does nothing.
   */
  public void render(Field field, String message, MarkupWriter writer,
FormSupport formSupport)
  {
  }

  /**
   * Passes the clientValue through unchanged.
   */
  public Date parseClient(Field field, String clientValue, String message)
  throws ValidationException
  {
  return Populator.getDate(clientValue, dd.MM.);
  }

  /**
   * Passes the value through unchanged.
   */
  public String toClient(Date value)
  {
  return Populator.getDate(dd.MM.);
  }
}

On Mon, Nov 16, 2009 at 11:33 PM, Inge Solvoll inge.tapes...@gmail.comwrote:

 Hi!

 I'm trying to create a mixin that puts a jquery datepicker on a regular
 TextField. It's working on a property of type String, but I get an error
 saying that 'translate is bound to null' if I try to use it on a field of
 type java.util.Date. I have contributed type coercions between String and
 Date, and I thought that was enough. Isn't it?

 Maybe I should just try to copy the built-in datepicker in T5, but it seems
 kind of complex, and it's hard to figure out what parts I actually need.



'translate' is bound to null

2009-11-16 Thread Inge Solvoll
Hi!

I'm trying to create a mixin that puts a jquery datepicker on a regular
TextField. It's working on a property of type String, but I get an error
saying that 'translate is bound to null' if I try to use it on a field of
type java.util.Date. I have contributed type coercions between String and
Date, and I thought that was enough. Isn't it?

Maybe I should just try to copy the built-in datepicker in T5, but it seems
kind of complex, and it's hard to figure out what parts I actually need.