Hi Bas,

Okay. Let me explain it more.

So far I used converters for date fields like this which has been worked fine.

        DateConverter dc = new DateConverter(true) {

            @Override
            public String getDatePattern(Locale locale) {
                return "yyyy.MM.dd";
            }

            @Override
            protected DateTimeFormatter getFormat(Locale locale) {
                DateTimeFormatter fm = DateTimeFormat.forPattern("yyyy.MM.dd");
                return fm;
            }
        };
        DateTextField form_tol = (DateTextField) new DateTextField("fDate", dc) {
            @Override
            public boolean isEnabled() {
                return status == null;
            }
        };

In wicket 9 I changed this to

DateTextField from = new DateTextField("fDate", new PropertyModel(model,"fDate"),"yyyy.MM.dd");

Now if I run my quickstart I get the following error msg:

 * 'fDate' is not Date type.

I have no idea how to get rid of it.

 I think all the validators refactoring is at the second place right now.

TIA,

Sandor



2025. 03. 25. 8:59 keltezéssel, Bas Gooren írta:
  Hi Sandor,

In your QuickStart (Homepage.java) I see that you are accessing the raw
field value.

Since you are using an input of type=“date”, the value will always have a
specific format:

https://developer.mozilla.org/en-US/docs/Web/HTML/Date_and_time_formats#date_strings
https://www.w3.org/TR/2011/WD-html-markup-20110405/input.date.html (RFC
3339 “full-date”)

The standard format is yyyy-mm-dd (or yyyy-MM-dd in java).

You shouldn’t need to access the underlying String value of the date field.
Instead, create a validator that implements IValidator<Date> and in its
#validate method access validatable.getValue() to get the Date provided by
the user.

So you don’t need to worry about converting the date yourself from String
to Date. You can simply run validations on the Date directly.

Met vriendelijke groet,
Kind regards,

Bas Gooren


Op 25 mrt 2025, 08:37:36 schreef Sandor Feher<sfe...@bluesystem.hu>:

Hi Bas,

Sorry for the delay..

I use org.apache.wicket.extensions.markup.html.form.DateTextField in my
project

Meanwhile I figured out that the problem probaly is not with pattern but
the Date field itself.

I created a quickstart for the better undestanding.

https://github.com/sfeher/wicket9DateTextFieldquickstart

Thank you.

2025. 03. 24. 12:54 keltezéssel, Bas Gooren írta:

   Hi Sandor,


Which DateTextField are you using? The one from wicket-extensions or

wicketstuff?


In general I’m not sure I follow: since both variations of DateTextField

have a model type Date, any validator will receive a Date.

So can you explain (or perhaps show some code) how exactly you are getting

a string in your validator?


Met vriendelijke groet,

Kind regards,


Bas Gooren


Op 21 maart 2025 bij 12:08:31, Sandor Feher (sfe...@bluesystem.hu)
schreef:


Hi,


At the moment I try to migrate my 7.x project to 9.20.0 and stumbled on

a problem using DateTextField.


However I pass date pattern to my fields DateTextField tol = new

DateTextField("from", model, "yyyy.MM.dd");


when I validate them they alway get their value back in DateFormat.SHORT

according to my language settings.


Thus all of my validators based on this pattern will fail.


So far I used DateConverter and as I realized it's not necessary anymore

becase I can pass pattern as a parameter.


So please let me know which is the proper way to use this component.


TIA,


Regards, Sandor



---------------------------------------------------------------------

To unsubscribe, e-mail:users-unsubscr...@wicket.apache.org

For additional commands, e-mail:users-h...@wicket.apache.org


--
Üdvözlettel/Kind Regards, Fehér Sándor


...Fehér Sándor...            ---    ....Sandor Feher....
  fejlesztési vezetõ           ---     development manager
  Blue System Kft.             ---      Blue System Ltd.

..........................................................................................
http://www.bluesystem.hu :http://www.adatmegorzo.hu :
http://www.bluehosting.hu

..........................................................................................

Kérem gondoljon a környezetre mielõtt kinyomtatná ezt az e-mailt vagy
bármely csatolmányát.
Please consider the environment before printing this e-mail and any
associated attachments.


--
Üdvözlettel/Kind Regards, Fehér Sándor


...Fehér Sándor...            ---    ....Sandor Feher....
 fejlesztési vezetõ           ---     development manager
 Blue System Kft.             ---      Blue System Ltd.
..........................................................................................
http://www.bluesystem.hu :http://www.adatmegorzo.hu :http://www.bluehosting.hu
..........................................................................................

Kérem gondoljon a környezetre mielõtt kinyomtatná ezt az e-mailt vagy bármely 
csatolmányát.
Please consider the environment before printing this e-mail and any associated 
attachments.

Reply via email to