You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mbelarbi <mb...@zoomf.com> on 2007/12/18 13:06:49 UTC

Retrieving TextField and TextArea text on submit

I have a simple TextArea in a simple Form that looks something like this:

public class MyForm extends Form {
        TextArea message
        TextField to;
        TextField subject;
	
	public EditorForm(String id) {
		super(id);

		message = new TextArea("textArea");
		to = new TextField("textArea");
		subject = new TextField("textArea");
		
		add(to);
		add(subject);
		add(message);
		add(new Button("submit"));
	}
	
	protected void onSubmit() {
		System.out.println("To:" + [WHAT EVER THE 'TO' TEXTFIELD HAS] )
		System.out.println("Subject:" + [WHAT EVER THE 'SUBJECT' TEXTFIELD HAS] )
		System.out.println("Message:" + [WHAT EVER THE 'MESSAGE' TEXTAREA HAS] )
	}
}


How do I retrieve and simply print out what ever the user has inputted into
the text fields and text area on submit? It seems like a simple thing, am I
missing something?

Thank you.
-- 
View this message in context: http://www.nabble.com/Retrieving-TextField-and-TextArea-text-on-submit-tp14395591p14395591.html
Sent from the Wicket - User 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: Retrieving TextField and TextArea text on submit

Posted by Florian Sperber <fl...@sperber.info>.
Hi,

use
   setModel(new CompoundPropertyModel(MyForm.this));
in your form constructor.

this automatically sets the submitted data to the corresponding properties

http://www.wicketstuff.org/wicket13/forminput/ has greate examples to study.


Kind regards,
Florian Sperber



mbelarbi schrieb:
> I have a simple TextArea in a simple Form that looks something like this:
> 
> public class MyForm extends Form {
>         TextArea message
>         TextField to;
>         TextField subject;
> 	
> 	public MyForm(String id) {
> 		super(id);
> 
> 		message = new TextArea("message");
> 		to = new TextField("to");
> 		subject = new TextField("subject");
> 		
> 		add(to);
> 		add(subject);
> 		add(message);
> 		add(new Button("submit"));
> 	}
> 	
> 	protected void onSubmit() {
> 		System.out.println("To:" + [WHAT EVER THE 'TO' TEXTFIELD HAS] )
> 		System.out.println("Subject:" + [WHAT EVER THE 'SUBJECT' TEXTFIELD HAS] )
> 		System.out.println("Message:" + [WHAT EVER THE 'MESSAGE' TEXTAREA HAS] )
> 	}
> }
> 
> 
> How do I retrieve and simply print out what ever the user has inputted into
> the text fields and text area on submit? It seems like a simple thing, am I
> missing something?
> 
> Thank you.


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