Re: Using forms defined in panels
Hi, the easiest solution is declare regModel as final, then you can "do something" as follows: form.add(new SubmitButton("register") { public void onSubmit() { // do something regModel.getObject().getUserName(); } }); Note that declaring models as final might me dangerous, since the model is kept in the component hierarchy but nobody detaches it. This is not the case here though, since RegistrationInputPanel will take care of it. Regards Sven On 26.02.2015 09:18, Andrew Hall wrote: Hi all, I have a newbie question ... In the free online guide for Wicket - best practices section,2 listings are provided as examples of how to encapsulate components in panels: (http://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_1) Listing 3:// Good component public class RegistrationInputPanel extends Panel{ public RegistrationInputPanel(String id, IModel regModel) { super(id, regModel); IModel compound = new CompoundPropertyModel form = new Form("form", compound); // Correct: Add components to Form over the instance variable form.add(new TextField("username")); form.add(new TextField("firstname")); form.add(new TextField("lastname")); add(form); } } Listing 4:public class RegistrationPage extends Page { public RegistrationPage(IModel regModel) { Form form = new Form("form"); form.add(new RegistrationInputPanel("registration", regModel); form.add(new SubmitButton("register") { public void onSubmit() { // do something } }); add(form); } } I infer from this example that it is possible in Wicket to decouple the physical definition of a form (listing 3) from the code which is executed when a form is submitted (listing 4). I suppose the point is that different pages can reuse the same physical form and implement their own form submission logic. Is it possible for the "// do something" in listing 4 to access the values of "username", "firstname" & "lastname" submitted through the form defined in listing 3? If the answer is yes, then could anyone provide a snippet of code demonstrating how to do this? I've had a search and have not found an obvious way! Thanks, Andrew. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Using forms defined in panels
Hi all, I have a newbie question ... In the free online guide for Wicket - best practices section,2 listings are provided as examples of how to encapsulate components in panels: (http://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_1) Listing 3:// Good component public class RegistrationInputPanel extends Panel{ public RegistrationInputPanel(String id, IModel regModel) { super(id, regModel); IModel compound = new CompoundPropertyModel form = new Form("form", compound); // Correct: Add components to Form over the instance variable form.add(new TextField("username")); form.add(new TextField("firstname")); form.add(new TextField("lastname")); add(form); } } Listing 4:public class RegistrationPage extends Page { public RegistrationPage(IModel regModel) { Form form = new Form("form"); form.add(new RegistrationInputPanel("registration", regModel); form.add(new SubmitButton("register") { public void onSubmit() { // do something } }); add(form); } } I infer from this example that it is possible in Wicket to decouple the physical definition of a form (listing 3) from the code which is executed when a form is submitted (listing 4). I suppose the point is that different pages can reuse the same physical form and implement their own form submission logic. Is it possible for the "// do something" in listing 4 to access the values of "username", "firstname" & "lastname" submitted through the form defined in listing 3? If the answer is yes, then could anyone provide a snippet of code demonstrating how to do this? I've had a search and have not found an obvious way! Thanks, Andrew.
Re: Using Forms
Hi, Take a look at the FormInput example in wicket example projects. Wicket examples have everything to get you started. Regards Dipu On Jan 14, 2008 8:58 AM, j.bokobza <[EMAIL PROTECTED]> wrote: > Hello > I'm new with wicket and I'm looking for samples of basics forms. > I didn't find how to retrieve datas (variables) sent by a wicket form > with method setResponsePage. > Can anyone help me ? Thanks. > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Using Forms
Hello I'm new with wicket and I'm looking for samples of basics forms. I didn't find how to retrieve datas (variables) sent by a wicket form with method setResponsePage. Can anyone help me ? Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]