Johan,

Thanks for the help.  Settled on this:

      final DateConverter conv = new DateConverter();
      final SimpleDateFormat sdf = new SimpleDateFormat("MM/yy");
      conv.setDateFormat(Locale.getDefault(), sdf);
      TextField exp = new RequiredTextField("expiration") {
        public IConverter getConverter() {
          return new SimpleConverterAdapter() {
            public String toString(Object value) {
              return value != null ? sdf.format(value) : null;
            }

            public Object toObject(String value) {
              try {
                return sdf.parse(value.toString());
              } catch (Exception e) {
                throw new ConversionException("'" + value
                    + "' is not a valid Date");
              }
            }
          };
        }
      };
      DatePicker picker = new DatePicker("expirationDatePicker", exp);
      picker.setDateConverter(conv);
      add(exp);
      add(picker);



Johan Compagner wrote:
> That way it is only used to format the string to the screen.
> The dateformatter is used to get the format out and javascript 
> dateformat is generated based on that
>
> That dateformatter should also be used by the textfield itself to 
> handle the formatting both ways.
> So override the getConverter() of the exp textfield and return als 
> your converter (that has to work 2 ways then!)
>
> johan
>
>
> On 8/11/06, *kurt heston * <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     I'm trying to create a field that allows filling in of a credit card
>     expiration date using 1.2.  What did I miss?
>
>     Code:
>
>           TextField exp = new RequiredTextField("expiration");
>           DatePicker picker = new DatePicker("expirationDatePicker",
>     exp);
>           DateConverter conv = new DateConverter();
>           conv.setDateFormat(Locale.getDefault(),new
>     SimpleDateFormat("MM/yyyy"));
>           picker.setDateConverter(conv);
>           add(exp);
>           add(picker);
>
>     Exception:
>
>         wicket.util.convert.ConversionException: Cannot parse '03/2006'
>     using format [EMAIL PROTECTED]
>              at
>     wicket.util.convert.converters.AbstractConverter.newConversionException
>     (AbstractConverter.java:72)
>              ...
>
>     -------------------------------------------------------------------------
>     Using Tomcat but need to do more? Need to support web services,
>     security?
>     Get stuff done quickly with pre-integrated technology to make your
>     job easier
>     Download IBM WebSphere Application Server v.1.0.1 based on Apache
>     Geronimo
>     http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>     <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
>     _______________________________________________
>     Wicket-user mailing list
>     Wicket-user@lists.sourceforge.net
>     <mailto:Wicket-user@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>   

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to