You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by xiaowang <jy...@gmail.com> on 2012/03/19 02:37:55 UTC

Why I cannot receive default value in Textfield?

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Why I cannot receive default value in Textfield?

Posted by xiaowang <jy...@gmail.com>.
Hi, thanks for the replay.
I checked onsubmit() and the value has not been transferred if I don't
delete the default value. 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Why-I-cannot-receive-default-value-in-Textfield-tp4483603p4486021.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: Why I cannot receive default value in Textfield?

Posted by James Carman <jc...@carmanconsulting.com>.
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" <jy...@gmail.com> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>