You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by vov <vo...@mail.ru> on 2011/03/15 14:40:02 UTC

Set FormComponent Type and EmailValidator

After submitting a form:

add(new Form("form") //
        .add(new TextField("text", new Model(), String.class) //
            .add(EmailAddressValidator.getInstance())))

with empty field the fallowing error occur:('' is not a valid email
address.)

Without setting type for TextField - all fine


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Set-FormComponent-Type-and-EmailValidator-tp3356588p3356588.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Set FormComponent Type and EmailValidator

Posted by Martin Grigorov <mg...@apache.org>.
On behalf of Pedro Sans:

Are u using the Wicket 1.4? I think it is related to
https://issues.apache.org/jira/browse/WICKET-3269 We improved text
components to respect the convertEmptyInputStringToNull property regardless
of the form component type in 1.5

On Tue, Mar 15, 2011 at 2:40 PM, vov <vo...@mail.ru> wrote:

> After submitting a form:
>
> add(new Form("form") //
>        .add(new TextField("text", new Model(), String.class) //
>            .add(EmailAddressValidator.getInstance())))
>
> with empty field the fallowing error occur:('' is not a valid email
> address.)
>
> Without setting type for TextField - all fine
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Set-FormComponent-Type-and-EmailValidator-tp3356588p3356588.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: Set FormComponent Type and EmailValidator

Posted by vov <vo...@mail.ru>.
Does anyone know how to solve this problem?
Or is it a bug in wicket?

Note: I use wicket 1.4.14

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Set-FormComponent-Type-and-EmailValidator-tp3356588p3387040.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Set FormComponent Type and EmailValidator

Posted by vov <vo...@mail.ru>.
I have a warning in my log if I use "new TextField("text", new Model()":

WARN  [org.apache.wicket.markup.html.form.AbstractTextComponent] Couldn't
resolve model type of
Model:classname=[org.apache.wicket.model.CompoundPropertyModel$AttachedCompoundPropertyModel]:nestedModel=[Model:classname=[org.apache.wicket.model.CompoundPropertyModel]:nestedModel=[Model:classname=[org.apache.wicket.model.Model]:object=[null]]]
for [MarkupContainer [Component id = email]], please set the type yourself.

If I set the type manually "new TextField("text", new Model(),
String.class)" the warning disappear.
But in this case I have a problem with EmailValidator.
The validation error occur because in case with setting type -
getConverterInput() return empty line, but not null.

The question is - how to fix warning in the log and escape validation error
in case if nothing has been input in the field

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Set-FormComponent-Type-and-EmailValidator-tp3356588p3382142.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Set FormComponent Type and EmailValidator

Posted by xFlasH <rc...@gmail.com>.
What is your real question ?

The error message ? The email validation mechanism ?

If you want a more precise message for the error message, put a Label on
your TextField :

Form f = new Form("form");
add(f);
TextField<String> tf = new TextField<String>("text", new Model(),
String.class);
f.add(tf);
tf.add(EmailAddressValidator.getInstance());
tf.setLabel(Model.of("Email validated TextField");


R


2011/3/15 vov [via Apache Wicket] <
ml-node+3356588-93268421-216345@n4.nabble.com>

> After submitting a form:
>
> add(new Form("form") //
>         .add(new TextField("text", new Model(), String.class) //
>             .add(EmailAddressValidator.getInstance())))
>
> with empty field the fallowing error occur:('' is not a valid email
> address.)
>
> Without setting type for TextField - all fine
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Set-FormComponent-Type-and-EmailValidator-tp3356588p3356588.html
>  To start a new topic under Users forum, email
> ml-node+1842947-98389252-216345@n4.nabble.com
> To unsubscribe from Users forum, click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842947&code=cmNvcXVldWduaW90QGdtYWlsLmNvbXwxODQyOTQ3fDE1MTA1ODc1MTA=>.
>
>


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Set-FormComponent-Type-and-EmailValidator-tp3356588p3381466.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org