You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by HHB <hu...@yahoo.ca> on 2009/04/19 16:11:20 UTC

Submitting form via Ajax isn't working

Hey,
I have a form and I want to submit it via Ajax:

<wicket:panel>
    <form wicket:id="form">
        <div wicket:id="feedback"></div>
        <table width="100%" cellpadding="2" cellspacing="2">
            <tr>
                <td><label><wicket:message key="name"/>
</label></td>
                <td><span wicket:id="nameBorder">
<input type="text" wicket:id="name"/></span></td>
            </tr>
            <tr>
                <td><wicket:message key="note"/></td>
                <td><textarea cols="20" rows="10" wicket:id="note"></textarea></td>
            </tr>
            <tr>
                <td colspan="2">
<input wicket:id="create" type="button" value="Create Group"/></td>
            </tr>
        </table>
    </form>
</wicket:panel>

    public CreateGroupPanel(String id) {
        super(id);
        setOutputMarkupId(true);
        final Form form = new Form("form", 
new CompoundPropertyModel(new Group()));
        add(form);
        form.add(new FeedbackPanel("feedback"));
        form.add(new 
FormComponentFeedbackBorder("nameBorder").add(new
TextField("name").setRequired(true)));
        form.add(new TextArea("note"));
        form.add(new AjaxSubmitLink("create") {
            @Override
            protected void onSubmit(AjaxRequestTarget target, 
Form form) {
                Group group = (Group) form.getModelObject();
                System.out.println("Logging: " + group);
            }
        });
    }

But nothing is got print on the console.
Any ideas what is going wrong?
FireFox 3.0.7
Ubuntu 8.10
Wicket 1.3.5
Thanks.


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


Re: Submitting form via Ajax isn't working

Posted by HHB <hu...@yahoo.ca>.
Yes, you are right.
My isssue is solved now, thanks.


cpopetz wrote:
> 
> All looks good to me, my guess is that you aren't entering in a name,
> and so you're failing validation, but you haven't implemented onError
> to add the feedback panel to the target in that  case.  Also, your
> feedback panel probably needs setOutputMarkupId(true) to be of any
> use, given that you're submitting with ajax.
> 
> -Clint
> 
> On Sun, Apr 19, 2009 at 9:11 AM, HHB <hu...@yahoo.ca> wrote:
>> Hey,
>> I have a form and I want to submit it via Ajax:
>>
>> <wicket:panel>
>>    <form wicket:id="form">
>>        <div wicket:id="feedback"></div>
>>        <table width="100%" cellpadding="2" cellspacing="2">
>>            <tr>
>>                <td><label><wicket:message key="name"/>
>> </label></td>
>>                <td>
>> <input type="text" wicket:id="name"/></td>
>>            </tr>
>>            <tr>
>>                <td><wicket:message key="note"/></td>
>>                <td><textarea cols="20" rows="10"
>> wicket:id="note"></textarea></td>
>>            </tr>
>>            <tr>
>>                <td colspan="2">
>> <input wicket:id="create" type="button" value="Create Group"/></td>
>>            </tr>
>>        </table>
>>    </form>
>> </wicket:panel>
>>
>>    public CreateGroupPanel(String id) {
>>        super(id);
>>        setOutputMarkupId(true);
>>        final Form form = new Form("form",
>> new CompoundPropertyModel(new Group()));
>>        add(form);
>>        form.add(new FeedbackPanel("feedback"));
>>        form.add(new
>> FormComponentFeedbackBorder("nameBorder").add(new
>> TextField("name").setRequired(true)));
>>        form.add(new TextArea("note"));
>>        form.add(new AjaxSubmitLink("create") {
>>            @Override
>>            protected void onSubmit(AjaxRequestTarget target,
>> Form form) {
>>                Group group = (Group) form.getModelObject();
>>                System.out.println("Logging: " + group);
>>            }
>>        });
>>    }
>>
>> But nothing is got print on the console.
>> Any ideas what is going wrong?
>> FireFox 3.0.7
>> Ubuntu 8.10
>> Wicket 1.3.5
>> Thanks.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Submitting-form-via-Ajax-isn%27t-working-tp23123367p23123825.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: Submitting form via Ajax isn't working

Posted by Clint Popetz <cp...@gmail.com>.
All looks good to me, my guess is that you aren't entering in a name,
and so you're failing validation, but you haven't implemented onError
to add the feedback panel to the target in that  case.  Also, your
feedback panel probably needs setOutputMarkupId(true) to be of any
use, given that you're submitting with ajax.

-Clint

On Sun, Apr 19, 2009 at 9:11 AM, HHB <hu...@yahoo.ca> wrote:
> Hey,
> I have a form and I want to submit it via Ajax:
>
> <wicket:panel>
>    <form wicket:id="form">
>        <div wicket:id="feedback"></div>
>        <table width="100%" cellpadding="2" cellspacing="2">
>            <tr>
>                <td><label><wicket:message key="name"/>
> </label></td>
>                <td><span wicket:id="nameBorder">
> <input type="text" wicket:id="name"/></span></td>
>            </tr>
>            <tr>
>                <td><wicket:message key="note"/></td>
>                <td><textarea cols="20" rows="10" wicket:id="note"></textarea></td>
>            </tr>
>            <tr>
>                <td colspan="2">
> <input wicket:id="create" type="button" value="Create Group"/></td>
>            </tr>
>        </table>
>    </form>
> </wicket:panel>
>
>    public CreateGroupPanel(String id) {
>        super(id);
>        setOutputMarkupId(true);
>        final Form form = new Form("form",
> new CompoundPropertyModel(new Group()));
>        add(form);
>        form.add(new FeedbackPanel("feedback"));
>        form.add(new
> FormComponentFeedbackBorder("nameBorder").add(new
> TextField("name").setRequired(true)));
>        form.add(new TextArea("note"));
>        form.add(new AjaxSubmitLink("create") {
>            @Override
>            protected void onSubmit(AjaxRequestTarget target,
> Form form) {
>                Group group = (Group) form.getModelObject();
>                System.out.println("Logging: " + group);
>            }
>        });
>    }
>
> But nothing is got print on the console.
> Any ideas what is going wrong?
> FireFox 3.0.7
> Ubuntu 8.10
> Wicket 1.3.5
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Submitting form via Ajax isn't working

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
You should implement the onError method of the button and update
feedback panel to see possible validation errors.

**
Martin

2009/4/19 HHB <hu...@yahoo.ca>:
> Hey,
> I have a form and I want to submit it via Ajax:
>
> <wicket:panel>
>    <form wicket:id="form">
>        <div wicket:id="feedback"></div>
>        <table width="100%" cellpadding="2" cellspacing="2">
>            <tr>
>                <td><label><wicket:message key="name"/>
> </label></td>
>                <td><span wicket:id="nameBorder">
> <input type="text" wicket:id="name"/></span></td>
>            </tr>
>            <tr>
>                <td><wicket:message key="note"/></td>
>                <td><textarea cols="20" rows="10" wicket:id="note"></textarea></td>
>            </tr>
>            <tr>
>                <td colspan="2">
> <input wicket:id="create" type="button" value="Create Group"/></td>
>            </tr>
>        </table>
>    </form>
> </wicket:panel>
>
>    public CreateGroupPanel(String id) {
>        super(id);
>        setOutputMarkupId(true);
>        final Form form = new Form("form",
> new CompoundPropertyModel(new Group()));
>        add(form);
>        form.add(new FeedbackPanel("feedback"));
>        form.add(new
> FormComponentFeedbackBorder("nameBorder").add(new
> TextField("name").setRequired(true)));
>        form.add(new TextArea("note"));
>        form.add(new AjaxSubmitLink("create") {
>            @Override
>            protected void onSubmit(AjaxRequestTarget target,
> Form form) {
>                Group group = (Group) form.getModelObject();
>                System.out.println("Logging: " + group);
>            }
>        });
>    }
>
> But nothing is got print on the console.
> Any ideas what is going wrong?
> FireFox 3.0.7
> Ubuntu 8.10
> Wicket 1.3.5
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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