Why I cannot receive default value in Textfield?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why I cannot receive default value in Textfield?

xiaowang
This post was updated on .
Hi,
Now I am using:

html -
<input type="text" wicket:id="ContactPerson1">
<input type="submit" wicket:id="submit"  value="Save">

Java -
public class MerchantEditPanel extends Panel {
private String ContactPerson1 = "some text";

       public MerchantEditPanel{
 TextField<String> ContactPerson1 = new TextField<String>("ContactPerson1",new PropertyModel(this,"ContactPerson1"));
       xxform. add(ContactPerson1);

       xxform.add(new AjaxSubmitLink("submit") {
            @Override
            protected void onSubmit(AjaxRequestTarget ajaxRequestTarget, Form<?> components) {
                                 Merchant m = (Merchant)components.getModelObject();
......
Here I find "m" cannot get the default value from ContactPerson textfield, or even I just add some words after "some text", components.getModelObject() cannot get the value from this textfield.
Ps:It can show default value "some text" in ContactPerson textfield.


And, if I try to use the code from http://wicketstuff.org/wicket14/compref/?wicket:bookmarkablePage=:org.apache.wicket.examples.compref.TextFieldPage, there is no default value in Textfield...

The code is:
public class MerchantEditPanel extends Panel {

private static class Input implements IClusterable
    {       public String ContactPerson1 = "some text"; }

         public MerchantEditPanel{
                       final Input input = new Input();
                       setDefaultModel(new CompoundPropertyModel<Input>(input));
                       xxform.add(new TextField<String>("ContactPerson1"));
                                            }

Can anyone help me? Thanks in advanced.
Reply | Threaded
Open this post in threaded view
|

Re: Why I cannot receive default value in Textfield?

James Carman-3
Check the value of the ContactPerson1 field in your onSubmit() method.  It
should contain what gets submitted.  The merchant object is unrelated to
your text field.
On Mar 18, 2012 9:38 PM, "xiaowang" <[hidden email]> wrote:

> Hi,
> Now I am using:
>
> html -
> <input type="text" wicket:id="ContactPerson1">
> <input type="submit" wicket:id="submit"  value="Save">
>
> Java -
> public class MerchantEditPanel extends Panel {
> private String ContactPerson1 = "some text";
>
>       public MerchantEditPanel{
>  TextField<String> ContactPerson1 = new
> TextField<String>("ContactPerson1",new
> PropertyModel(this,"ContactPerson1"));
>       xxform. add(ContactPerson1);
>
> frmEdit.add(new AjaxSubmitLink("submit") {
> @Override
>            protected void onSubmit(AjaxRequestTarget ajaxRequestTarget,
> Form<?> components) {
>                                 Merchant m =
> (Merchant)components.getModelObject();
> ......
> Here I find "m" cannot get the default value from ContactPerson textfield,
> or even I just add some words after "some text",
> components.getModelObject()
> cannot get the value from this textfield.
> Ps:It can show default value "some text" in ContactPerson textfield.
>
>
> And, if I try to use the code from
>
> http://wicketstuff.org/wicket14/compref/?wicket:bookmarkablePage=:org.apache.wicket.examples.compref.TextFieldPage
> ,
> there is no default value in Textfield...
>
> Can anyone help me? Thanks in advanced.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Why-I-cannot-receive-default-value-in-Textfield-tp4483603p4483603.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Why I cannot receive default value in Textfield?

xiaowang
This post was updated on .
Hi, thanks for the replay.
How can I check the onSubmit() to see whether or not default value has been received?
Use: Object o=components.getModelObject(); and System.out.println(o.xxxx);?
Please be a little bit more specific.

Thank you very much!