Let your panel have an onSubmit method, and let your form delegate calls
to its onSubmit to the panels onSubmit.
What do you mean by 'extend the form'? add more form fields?
that doesn't work like this, because you have to match the panel's markup.
you could use some kind of repeater or listview and generate your
form fields dynamically, using data from your panel's subclass.

On Wed, Feb 11, 2009 at 3:59 PM, pieter claassen
<[email protected]> wrote:
> But how do you then extend the form in the panel and more importantly, how
> do you override the onSubmit() method of that form?
>
> Cheers,
> Pieter
>
> On Wed, Feb 11, 2009 at 3:50 PM, Ryan Gravener <[email protected]>wrote:
>
>> I usually make a panel, add the form to the panel and write up the form in
>> the panel's markup.
>>
>>
>> http://wicketstuff.org/wicket13/signin/?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignIn
>>
>> Ryan Gravener
>> http://ryangravener.com/flex | http://twitter.com/ryangravener
>>
>>
>> On Wed, Feb 11, 2009 at 9:40 AM, pieter claassen <[email protected]
>> >wrote:
>>
>> > I am trying to move a form from an inner class that extends Form to a
>> > public
>> > class. This is so that I can override the onSubmit() method of my form.
>> >
>> > Below are my files.
>> >
>> > When I add the form to a wicket page with
>> >
>> > add(new TemplateEditForm("templateeditform", templatemodel));
>> >
>> > and the corresponding html code
>> >
>> > <form wicket:id="templateeditform">editform</form>
>> >
>> > My wicket code doesn't pick the wicket:ids in the TemplateEditForm.html
>> > file
>> > up
>> >
>> > WicketMessage: The component(s) below failed to render. A common
>> > problem is that you have added a component in code but forgot to
>> > reference it in the markup (thus the component will never be
>> > rendered).
>> >
>> > 1. [MarkupContainer [Component id = name]]
>> > 2. [MarkupContainer [Component id = version]]
>> > 3. [MarkupContainer [Component id = author]]
>> > 4. [MarkupContainer [Component id = active]]
>> > 5. [MarkupContainer [Component id = description]]
>> > 6. [MarkupContainer [Component id = textarea]]
>> > 7. [MarkupContainer [Component id = type]]
>> > 8. [MarkupContainer [Component id = submit]]
>> >
>> > I am sure I am doing something stupid, but I cannot find the solution to
>> > this. Any ideas?
>> >
>> > =====
>> >
>> > public class TemplateEditForm extends Form {
>> >
>> >    private TemplateWebModel templatemodel;
>> >
>> >    public TemplateEditForm(String id, TemplateWebModel templatemodel) {
>> >        super(id);
>> >        this.templatemodel = templatemodel;
>> >        setModel(new CompoundPropertyModel(templatemodel));
>> >        add(new RequiredTextField("name"));
>> >        add(new RequiredTextField("version", java.lang.Long.class));
>> >        add(new RequiredTextField("author"));
>> >        add(new CheckBox("active"));
>> >        add(new VariableTextFieldPanel("description", new PropertyModel(
>> >                templatemodel.getObject(), "description")));
>> >        DropDownChoice ddc = new DropDownChoice("type", Arrays
>> >                .asList(TemplateType.values()), new IChoiceRenderer() {
>> >
>> >            public Object getDisplayValue(Object object) {
>> >                return getString(object.toString());
>> >            }
>> >
>> >            public String getIdValue(Object object, int index) {
>> >                return object.toString();
>> >            }
>> >
>> >        });
>> >        ddc.setRequired(true);
>> >        add(ddc);
>> >        add(new Button("submit", new ResourceModel("submit")));
>> >
>> >    }
>> >
>> >    @Override
>> >    public void onSubmit() {
>> >        WicketApplication.get().getTemplateFactory().store(
>> >                templatemodel.getEntity());
>> >        setResponsePage(new TemplateListPage());
>> >    }
>> > }
>> >
>> > And the corresponding html code
>> >
>> > =======
>> >
>> >
>> > <wicket:extend>
>> >    <table>
>> >        <tr>
>> >            <td><wicket:message key="name" /></td>
>> >            <td><input wicket:id="name" /></td>
>> >        </tr>
>> >        <tr>
>> >            <td><wicket:message key="version" /></td>
>> >            <td><input wicket:id="version" /></td>
>> >        </tr>
>> >        <tr>
>> >            <td><wicket:message key="author" /></td>
>> >            <td><input wicket:id="author" /></td>
>> >        </tr>
>> >        <tr>
>> >            <td><wicket:message key="active" /></td>
>> >            <td><input type="checkbox" wicket:id="active" /></td>
>> >        </tr>
>> >        <tr>
>> >            <td><wicket:message key="description" /></td>
>> >            <td><span wicket:id="description"></span></td>
>> >        </tr>
>> >        <tr>
>> >            <td><wicket:message key="type" /></td>
>> >            <td><select wicket:id="type">
>> >                <option></option>
>> >            </select></td>
>> >        </tr>
>> >
>> >        <tr>
>> >            <td colspan="2"><input wicket:id="submit" type="submit"></td>
>> >        </tr>
>> >    </table>
>> > </wicket:extend>
>> >
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to