That's what I tried to do. I created CnavForm.java and CnavForm.html. In the latter file I have this <wicket:panel> <form wicket:id="cnavForm"...> // form details </form> </wicket:panel>
Then I have CnavModify.java and CnavModify.html. You already see what I have in CnavModify.java from my last email. My CnavModify.html has this. <wicket:extend> <span wicket:id="cnavFormArea">Here's the form</span> </wicket:extend> Rather than render I'm getting this error: Last cause: Component [cnavFormArea] (path = [0:cnavFormArea]) must be applied to a tag of type [form], not: '<span wicket:id="cnavFormArea" id="cnavFormArea3">' (line 0, column 0) I'll keep trying and report back when I figure it out. Daniel On Tue, Jul 16, 2013 at 10:50 PM, Paul Bors <p...@bors.ws> wrote: > Wicket is a MVC component driven framework similar to Swing. > In short, what you want to do is create your own Panel with that form file > of yours and add it to another Panel as a child. > > See chapter 4 "Keeping control over HTML" of the Wicket Free Guide at: > http://code.google.com/p/wicket-guide/ > > Also available from under the Learn section as the Books link on the right > side navigation section on Wicket's home page at: > http://wicket.apache.org/learn/books/ > > ~ Thank you, > Paul Bors > > -----Original Message----- > From: Daniel Watrous [mailto:dwmaill...@gmail.com] > Sent: Tuesday, July 16, 2013 7:13 PM > To: users@wicket.apache.org > Subject: Re: Form questions > > Thanks Paul and Sven. I got the form to work and available in the onSubmit > handler. > > Now I'm interested in splitting the form out into it's one file. So I > created a class that has nothing more than the form, but I'm not sure how > to > include this into a page. > > In my class I do this: > > public class CnavModify extends ConsoleBasePage { > > public CnavModify(PageParameters parameters) { > super(parameters); > > Form form = new CnavForm("cnavFormArea"); > add(form); > } > } > > My CnavModify obviously extends a base page. What do I put inside the > <wicket:extend> tag to have the form render? > > Daniel > > > On Tue, Jul 16, 2013 at 12:00 AM, Sven Meier <s...@meiers.net> wrote: > > > Hi, > > > > > > Some problems I can't figure out. The code to create the button > > complains > >> that it requires a CnavUrl but gets back a String. > >> > >> add(new Button("publish", model) { > >> @Override > >> public void onSubmit() { > >> CnavUrl cnavUrl = (CnavUrl) getModelObject(); > >> System.out.println("publish"); > >> } > >> }); > >> > > > > a Button always has a IModel<String> to fill the value attribute. Note > > that in #onSubmit() you're getting the model object of the button, not > > of your form. > > You can write: > > > > add(new Button("publish", model) { > >> @Override > >> public void onSubmit() { > >> CnavUrl cnavUrl = (CnavUrl) MyForm.this.getModelObject(); > >> System.out.println("publish"); > >> } > >> }); > >> > > > > Using generic types in your code should help you. > > > > Sven > > > > > > > > On 07/15/2013 11:41 PM, Daniel Watrous wrote: > > > >> Hello, > >> > >> I'm interested in creating a single Form that will accommodate the > >> following use cases > >> 1) display blank for creating new records > >> 2) pre-populate for editing existing records > >> 3) map submitted values on to an existing domain object > >> 4) accommodate two actions, Save Draft -or- Publish > >> > >> I'm following Wicket in Action and within my Form constructor I > >> create my model, like this > >> > >> CnavUrl cnavUrl = new BasicCnavUrl(); > >> IModel model = new Model((Serializable) cnavUrl); > >> setModel(model); > >> > >> I then use PropertyModel > >> > >> add(new TextField("url", new PropertyModel(cnavUrl, > >> "url"))); > >> > >> For the two actions, I'm creating the Button objects like this > >> > >> add(new Button("publish", model) { > >> @Override > >> public void onSubmit() { > >> CnavUrl cnavUrl = (CnavUrl) getModelObject(); > >> System.out.println("publish"); > >> } > >> }); > >> > >> Some problems I can't figure out. The code to create the button > >> complains that it requires a CnavUrl but gets back a String. > >> > >> It seems that a new BasicCnavUrl is created once with the Form. What > >> happens on subsequent calls? Can I always expect my model to have the > >> data from the current form submission? > >> > >> Is there a best way to incorporate the idea of an edit, where the > >> model is pre-populated from a data source and pre-fills the Form fields? > >> > >> Thanks, > >> Daniel > >> > >> > > > > ------------------------------**------------------------------**------ > > --- To unsubscribe, e-mail: > > users-unsubscribe@wicket.**apache.org<users-unsubscribe@wicket.apache. > > org> For additional commands, e-mail: users-h...@wicket.apache.org > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >