Please create a quickstart and share it somewhere.

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

On Sat, Oct 15, 2016 at 1:02 PM, ganea iulia <superbiss...@gmail.com> wrote:

> Hello,
>
> Do you have any new advise on this?
> Thank you.
>
> On Fri, Oct 14, 2016 at 11:02 AM, ganea iulia <superbiss...@gmail.com>
> wrote:
>
> > Hello,
> > But that was it.
> > The code contained both the
> > txtName.setOutputMarkupId(true) and the
> > txtName.add(new AjaxFormComponentUpdatingBehavior("change") { ...
> >
> >
> > I will paste all the code again (I have now only added the
> > txtLink.setOutputMarkupId(true) and the TestForm.setOutputMarkupId(
> true);
> > )
> > Thank you
> >
> > ==HTML code==
> > <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>
> >
> > ==JAVA CODE==
> >
> > public class TestPage extends WebPage {
> >
> > private static final long serialVersionUID = 311508940740808005L;
> > private static final Logger logger = LogManager.getLogger(TestPage.
> class);
> >
> > public TestPage(IModel<TestBean> model) {
> > super(model);
> >
> > TestForm tst = new TestForm("testForm", model);
> > tst.setOutputMarkupId(true);
> > add(tst);
> >
> > }
> >
> > 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.setOutputMarkupId(true);
> > txtName.add(new AjaxFormComponentUpdatingBehavior("change") {
> > private static final long serialVersionUID = 1654345477970524731L;
> >
> > @Override
> > protected void onUpdate(AjaxRequestTarget target) {
> > target.add(txtName);
> > }
> >
> > });
> >
> > 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);
> >
> > }
> >
> > };
> > clearLink.setOutputMarkupId(true);
> > add(clearLink);
> > }
> >
> > @Override
> > protected void onSubmit() {
> >
> > logger.info("OnSubmit");
> >
> > }
> > }
> >
> >
> > }
> >
> >
> > ==THE BEAN==
> >
> > import java.io.Serializable;
> >
> > public class TestBean implements Serializable{
> >
> > /**
> > *
> > */
> > private static final long serialVersionUID = 1L;
> > private String name;
> > private String code;
> > private Integer id;
> > public String getName() {
> > return name;
> > }
> > public void setName(String name) {
> > this.name = name;
> > }
> > public String getCode() {
> > return code;
> > }
> > public void setCode(String code) {
> > this.code = code;
> > }
> > public Integer getId() {
> > return id;
> > }
> > public void setId(Integer id) {
> > this.id = id;
> > }
> >
> > }
> >
> >
> >
> > On Fri, Oct 14, 2016 at 10:43 AM, Martin Grigorov <mgrigo...@apache.org>
> > wrote:
> >
> >> 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