I don't know if I understand you right but enclosed is a component which behaves (and is) exactly like a Wicket Button but renders instead <a href="javascript:document.generatedFormName.submit()">, which triggers the form submit.

One of the SubmitLinks must be given the form in the constructor to register an AttributeModifier, which sets the name attribute of the form.

The usage is:

        final MyModel mod = new MyModel();
        Form f = new Form("linkForm", new CompoundPropertyModel(mod));
        f.add(new TextField("value1"));
        f.add(new SubmitLink("link1", f) {
            protected void onSubmit() {
                System.out.println("Link1 was clicked, value1 is: "
                        + mod.getValue1());
            };
        });
        f.add(new SubmitLink("link2") {
            protected void onSubmit() {
                System.out.println("Link2 was clicked, value1 is: "
                        + mod.getValue1());
            };
        });
html:

    <form wicket:id="linkForm" >
        <input wicket:id="value1" type="text" size="30"/>
        <a wicket:id="link1">Press link1 to submit</a>
        <a wicket:id="link2">Press link 2 to submit</a>
        <input type="submit" value="Send"/>
    </form>

Hope that helps,

Christian

On Sun, 20 Nov 2005 21:28:54 -0300, Manuel Corrales <[EMAIL PROTECTED]> wrote:

Maybe i was not clear about my problem. What i need is that when i click the
link get some info and redirect to other page. So far, the only way i can
get the info is getting the model on the onSubmit method, but that method i
use it for redirect to a diferent page.

On 11/20/05, Johan Compagner <[EMAIL PROTECTED]> wrote:

then you need to do an onClick on the button that submits the form.
only at this time you can't know that that link was clicked (or you have
to do that with a special hidden field and check that field in the
Form.submit () method)

johan


On 11/20/05, Manuel Corrales <[EMAIL PROTECTED]> wrote:
>
> Hi, i have a page with a small form, a couple links and a button
> (submit).
> Now, when the button is pressed, i can get the model data, but i need
> that when a link is clicked, get some data of the form.
>
> How can i achieve this?
>
> Thanks.
>





--
Christian Essl 

Attachment: SubmitLink.java
Description: Binary data

Reply via email to