We can only advise on the code that you give us.
Your real code may not work for many other reasons but since you give us
some incomplete copies of it we have no idea what is wrong.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Oct 14, 2016 at 9:33 AM, ganea iulia <superbiss...@gmail.com> wrote:

> Hello,
>
> The txtName field has the .setOutputMarkupId(true).
> I have also added it to the form.
> But it doesn't work howevere.
> I have event tested adding it to the txtLink, but still no change.
>
> However, the issue appears to come from the
> txtName.add(new AjaxFormComponentUpdatingBehavior("change") {...}
>
> If I comment out this part, the clear is done.
> But I need to have this behaviour kept.
>
> Could you please advise?
> Thank you
>
>
> On Fri, Oct 14, 2016 at 10:10 AM, Martin Grigorov <mgrigo...@apache.org>
> wrote:
>
> > On Fri, Oct 14, 2016 at 9:01 AM, ganea iulia <superbiss...@gmail.com>
> > wrote:
> >
> > > Hello,
> > >
> > > I'm using Wicket 7.
> > >
> > > Please help me with the following.
> > >
> > > I have a test form, with only one input text field on it.
> > > When pressing on a link, I need to have the values in the form cleared
> > out.
> > >
> > > This is the html and java code, but I could not make it work, the input
> > > field just won't clear.
> > >
> > > <form wicket:id="testForm">
> > > <table class="contenidoform"  cellpadding=1 cellspacing=0 border="0"
> > > width="100%">
> > > <tr>
> > > <th>Name:</th>
> > > <th colspan="3">
> > > <input wicket:id="txtName" size="80"/>
> > > </th>
> > > </tr>
> > > <tr>
> > > <th>
> > > <span><a href="#" wicket:id="clearLink"><img src="images/img.gif"
> > > name="btnClear" /></a></span>
> > > </th>
> > > </tr>
> > > </table>
> > > </form>
> > >
> > >
> > >
> > > public TestPage(IModel<TestBean> model, final ReturnObjectPage
> > returnPage)
> > > {
> > > super(model);
> > > this.returnPage = returnPage;
> > >
> >
> > Don't keep references to other pages.
> > Use PageReference instead.
> >
> >
> > >
> > > add(new TestForm("testForm", model));
> > >
> > > }
> > >
> > > class TestForm extends Form<TestBean> {
> > > /**
> > > *
> > > */
> > > private static final long serialVersionUID = 1L;
> > >
> > >
> > > public TestForm(String id, IModel<TestBean> model) {
> > > super(id, model);
> > > TextField<String> txtName = new TextField<String>("txtName", new
> > > PropertyModel<String>(getModelObject(), "name"));
> > > add(txtName);
> > > txtName.add(new AjaxFormComponentUpdatingBehavior("change") {
> > > private static final long serialVersionUID = 1654345477970524731L;
> > >
> > > @Override
> > > protected void onUpdate(AjaxRequestTarget target) {
> > > target.add(txtName);
> > > }
> > >
> > > });
> > > txtName.setOutputMarkupId(true);
> > > AjaxLink<TestBean> clearLink = new AjaxLink<TestBean>("clearLink",
> > model)
> > > {
> > > /**
> > > *
> > > */
> > > private static final long serialVersionUID = 1L;
> > >
> > > @Override
> > > public void onClick(AjaxRequestTarget target) {
> > > model.setObject(new TestBean());
> > > TestForm.this.clearInput();
> > > target.add(TestForm.this);
> > > target.add(txtName);
> > >
> >
> > 1. There is no need to add 'txtName' to the target because its parent
> > (TestForm) is added
> > 2. Neither of them have .setOutputMarkupId(true), so Wicket won't be able
> > to update them in the DOM. It should even complain about this.
> >
> >
> > > }
> > >
> > > };
> > > add(clearLink);
> > > }
> > > @Override
> > > protected void onSubmit() {
> > >
> > > logger.info("OnSubmit");
> > >
> > > }
> > > }
> > >
> >
>

Reply via email to