You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Clément Tamisier <cl...@gmail.com> on 2011/01/24 00:05:37 UTC

wicket nested form and modal

Hi, I have something strange with wicket 1.4 and I don't find what.
I have 2 nested forms. The inner form (form2) is in a modal window, and when
I validate this form (form2) the checkbox of "main" form (form1) become
unchecked (which is initially checked).

to test: click on "click" and submit the form of modal window showed ->
checkbox become unchecked.

PS : if I uncheck my checkbox manually and retry, it's works.

I include this this project in the mail. You can launch it with: "mvn clean
compile jetty:run"

Do you have any ideas. Thank you very much.

Cl�ment


*HelloWorld.java*
public class HelloWorld extends WebPage {
 private CheckBox checkbox;
 private ModalWindow modalWindow;

@SuppressWarnings("serial")
 public HelloWorld() {
Form<Object> form = new Form<Object>("form1");
 add(new AjaxLink<Object>("click") {

@Override
 public void onClick(AjaxRequestTarget target) {
modalWindow.show(target);
 }
});

checkbox = new CheckBox("checkbox",* new Model<Boolean>(true)*);
 checkbox.add(new OnChangeAjaxBehavior() {
 @Override
protected void onUpdate(AjaxRequestTarget target) {
System.out.println("checkbox set to :"+checkbox.getModelObject());
 }
});
 checkbox.setOutputMarkupId(true);
modalWindow = new ModalWindow("modal");
 SubmitPanel panel = new SubmitPanel("content", checkbox, modalWindow);
modalWindow.setContent(panel);
 form.add(checkbox);
form.add(modalWindow);
form.add(new AjaxButton("submitForm") {
 @Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
 System.out.println("on submit checkbox is :"+checkbox.getModelObject());
 }
});
add(form);
 }
}


*HelloWorld.html*
<html>
<body>
<form wicket:id="form1">
 <div wicket:id="modal"></div>
<input type="checkbox" wicket:id="checkbox" />
 <input type="submit" wicket:id="submitForm" />
</form>

<a wicket:id="click">click</a>

</body>
</html>


*SubmitPanel.java*
public class SubmitPanel extends Panel{
public SubmitPanel(String id, final CheckBox checkbox, final ModalWindow
modalWindow) {
 super(id);
Form<Object> form =new Form<Object>("form2");
 form.add(new AjaxButton("submitForm2") {
 @Override
 protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
*checkbox.setModelObject(true);*
 target.addComponent(checkbox);
modalWindow.close(target);
}

});
add(form);
}
}


*SubmitPanel.html*
<wicket:panel>
<form wicket:id="form2">
 <input type="submit" wicket:id="submitForm2" />
</form>
</wicket:panel>

Re: wicket nested form and modal

Posted by Igor Vaynberg <ig...@gmail.com>.
check that checkboxes still work correctly since browser doesnt send
anything (not even the name) when they are unchecked.

-igor

On Mon, Jan 24, 2011 at 11:45 AM, Pedro Santos <pe...@gmail.com> wrote:
> Linking the thread with the existing ticket:
> https://issues.apache.org/jira/browse/WICKET-1826
> <https://issues.apache.org/jira/browse/WICKET-1826>I attached the described
> patch in it.
>
> On Mon, Jan 24, 2011 at 5:30 PM, Pedro Santos <pe...@gmail.com> wrote:
>
>> At the linked thread Matej wrote about serialize the parent form of the
>> modal inner form on its submit. I think it would end up sending unnecessary
>> data back to server, since it is quite safe assume that user did not change
>> anything outside the modal window.
>>
>> The FormComponent#inputChanged method are assuming that if the form
>> component is nullable it can live with the nullified rawInput. But it is not
>> true, it would be better assume when form input name is not set in request
>> parameters that there is no raw input. I tested this change on 1.4, fix the
>> quickstart and all tests on the wicket 1.4.
>>
>> I'll give this change more test, but if you already know an potential
>> problem on it give me a tip.
>>
>>
>> ---------- Forwarded message ----------
>> From: Martin Makundi <ma...@koodaripalvelut.com>
>> Date: Mon, Jan 24, 2011 at 3:31 AM
>> Subject: Re: wicket nested form and modal
>> To: users@wicket.apache.org
>>
>>
>> Here is a workaround
>> http://www.mail-archive.com/users@wicket.apache.org/msg35946.html
>>
>> **
>> Martin
>>
>> 2011/1/24 Clément Tamisier <cl...@gmail.com>:
>> > Hi, I have something strange with wicket 1.4 and I don't find what.
>> > I have 2 nested forms. The inner form (form2) is in a modal window, and
>> when
>> > I validate this form (form2) the checkbox of "main" form (form1) become
>> > unchecked (which is initially checked).
>> > to test: click on "click" and submit the form of modal window showed ->
>> > checkbox become unchecked.
>> > PS : if I uncheck my checkbox manually and retry, it's works.
>> > I include this this project in the mail. You can launch it with: "mvn
>> clean
>> > compile jetty:run"
>> > Do you have any ideas. Thank you very much.
>> > Clément
>> >
>> > HelloWorld.java
>> > public class HelloWorld extends WebPage {
>> > private CheckBox checkbox;
>> > private ModalWindow modalWindow;
>> > @SuppressWarnings("serial")
>> > public HelloWorld() {
>> > Form<Object> form = new Form<Object>("form1");
>> > add(new AjaxLink<Object>("click") {
>> > @Override
>> > public void onClick(AjaxRequestTarget target) {
>> > modalWindow.show(target);
>> > }
>> > });
>> > checkbox = new CheckBox("checkbox", new Model<Boolean>(true));
>> > checkbox.add(new OnChangeAjaxBehavior() {
>> > @Override
>> > protected void onUpdate(AjaxRequestTarget target) {
>> > System.out.println("checkbox set to :"+checkbox.getModelObject());
>> > }
>> > });
>> > checkbox.setOutputMarkupId(true);
>> > modalWindow = new ModalWindow("modal");
>> > SubmitPanel panel = new SubmitPanel("content", checkbox, modalWindow);
>> > modalWindow.setContent(panel);
>> > form.add(checkbox);
>> > form.add(modalWindow);
>> > form.add(new AjaxButton("submitForm") {
>> > @Override
>> > protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>> > System.out.println("on submit checkbox is :"+checkbox.getModelObject());
>> > }
>> > });
>> > add(form);
>> > }
>> > }
>> >
>> > HelloWorld.html
>> > <html>
>> > <body>
>> > <form wicket:id="form1">
>> > <div wicket:id="modal"></div>
>> > <input type="checkbox" wicket:id="checkbox" />
>> > <input type="submit" wicket:id="submitForm" />
>> > </form>
>> > <a wicket:id="click">click</a>
>> > </body>
>> > </html>
>> >
>> > SubmitPanel.java
>> > public class SubmitPanel extends Panel{
>> > public SubmitPanel(String id, final CheckBox checkbox, final ModalWindow
>> > modalWindow) {
>> > super(id);
>> > Form<Object> form =new Form<Object>("form2");
>> > form.add(new AjaxButton("submitForm2") {
>> > @Override
>> > protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>> > checkbox.setModelObject(true);
>> > target.addComponent(checkbox);
>> > modalWindow.close(target);
>> > }
>> > });
>> > add(form);
>> > }
>> > }
>> >
>> > SubmitPanel.html
>> > <wicket:panel>
>> > <form wicket:id="form2">
>> > <input type="submit" wicket:id="submitForm2" />
>> > </form>
>> > </wicket:panel>
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>>
>>
>>
>> --
>> Pedro Henrique Oliveira dos Santos
>>
>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>

Re: wicket nested form and modal

Posted by Pedro Santos <pe...@gmail.com>.
Linking the thread with the existing ticket:
https://issues.apache.org/jira/browse/WICKET-1826
<https://issues.apache.org/jira/browse/WICKET-1826>I attached the described
patch in it.

On Mon, Jan 24, 2011 at 5:30 PM, Pedro Santos <pe...@gmail.com> wrote:

> At the linked thread Matej wrote about serialize the parent form of the
> modal inner form on its submit. I think it would end up sending unnecessary
> data back to server, since it is quite safe assume that user did not change
> anything outside the modal window.
>
> The FormComponent#inputChanged method are assuming that if the form
> component is nullable it can live with the nullified rawInput. But it is not
> true, it would be better assume when form input name is not set in request
> parameters that there is no raw input. I tested this change on 1.4, fix the
> quickstart and all tests on the wicket 1.4.
>
> I'll give this change more test, but if you already know an potential
> problem on it give me a tip.
>
>
> ---------- Forwarded message ----------
> From: Martin Makundi <ma...@koodaripalvelut.com>
> Date: Mon, Jan 24, 2011 at 3:31 AM
> Subject: Re: wicket nested form and modal
> To: users@wicket.apache.org
>
>
> Here is a workaround
> http://www.mail-archive.com/users@wicket.apache.org/msg35946.html
>
> **
> Martin
>
> 2011/1/24 Clément Tamisier <cl...@gmail.com>:
> > Hi, I have something strange with wicket 1.4 and I don't find what.
> > I have 2 nested forms. The inner form (form2) is in a modal window, and
> when
> > I validate this form (form2) the checkbox of "main" form (form1) become
> > unchecked (which is initially checked).
> > to test: click on "click" and submit the form of modal window showed ->
> > checkbox become unchecked.
> > PS : if I uncheck my checkbox manually and retry, it's works.
> > I include this this project in the mail. You can launch it with: "mvn
> clean
> > compile jetty:run"
> > Do you have any ideas. Thank you very much.
> > Clément
> >
> > HelloWorld.java
> > public class HelloWorld extends WebPage {
> > private CheckBox checkbox;
> > private ModalWindow modalWindow;
> > @SuppressWarnings("serial")
> > public HelloWorld() {
> > Form<Object> form = new Form<Object>("form1");
> > add(new AjaxLink<Object>("click") {
> > @Override
> > public void onClick(AjaxRequestTarget target) {
> > modalWindow.show(target);
> > }
> > });
> > checkbox = new CheckBox("checkbox", new Model<Boolean>(true));
> > checkbox.add(new OnChangeAjaxBehavior() {
> > @Override
> > protected void onUpdate(AjaxRequestTarget target) {
> > System.out.println("checkbox set to :"+checkbox.getModelObject());
> > }
> > });
> > checkbox.setOutputMarkupId(true);
> > modalWindow = new ModalWindow("modal");
> > SubmitPanel panel = new SubmitPanel("content", checkbox, modalWindow);
> > modalWindow.setContent(panel);
> > form.add(checkbox);
> > form.add(modalWindow);
> > form.add(new AjaxButton("submitForm") {
> > @Override
> > protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> > System.out.println("on submit checkbox is :"+checkbox.getModelObject());
> > }
> > });
> > add(form);
> > }
> > }
> >
> > HelloWorld.html
> > <html>
> > <body>
> > <form wicket:id="form1">
> > <div wicket:id="modal"></div>
> > <input type="checkbox" wicket:id="checkbox" />
> > <input type="submit" wicket:id="submitForm" />
> > </form>
> > <a wicket:id="click">click</a>
> > </body>
> > </html>
> >
> > SubmitPanel.java
> > public class SubmitPanel extends Panel{
> > public SubmitPanel(String id, final CheckBox checkbox, final ModalWindow
> > modalWindow) {
> > super(id);
> > Form<Object> form =new Form<Object>("form2");
> > form.add(new AjaxButton("submitForm2") {
> > @Override
> > protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> > checkbox.setModelObject(true);
> > target.addComponent(checkbox);
> > modalWindow.close(target);
> > }
> > });
> > add(form);
> > }
> > }
> >
> > SubmitPanel.html
> > <wicket:panel>
> > <form wicket:id="form2">
> > <input type="submit" wicket:id="submitForm2" />
> > </form>
> > </wicket:panel>
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>



-- 
Pedro Henrique Oliveira dos Santos

Fwd: wicket nested form and modal

Posted by Pedro Santos <pe...@gmail.com>.
At the linked thread Matej wrote about serialize the parent form of the
modal inner form on its submit. I think it would end up sending unnecessary
data back to server, since it is quite safe assume that user did not change
anything outside the modal window.

The FormComponent#inputChanged method are assuming that if the form
component is nullable it can live with the nullified rawInput. But it is not
true, it would be better assume when form input name is not set in request
parameters that there is no raw input. I tested this change on 1.4, fix the
quickstart and all tests on the wicket 1.4.

I'll give this change more test, but if you already know an potential
problem on it give me a tip.


---------- Forwarded message ----------
From: Martin Makundi <ma...@koodaripalvelut.com>
Date: Mon, Jan 24, 2011 at 3:31 AM
Subject: Re: wicket nested form and modal
To: users@wicket.apache.org


Here is a workaround
http://www.mail-archive.com/users@wicket.apache.org/msg35946.html

**
Martin

2011/1/24 Clément Tamisier <cl...@gmail.com>:
> Hi, I have something strange with wicket 1.4 and I don't find what.
> I have 2 nested forms. The inner form (form2) is in a modal window, and
when
> I validate this form (form2) the checkbox of "main" form (form1) become
> unchecked (which is initially checked).
> to test: click on "click" and submit the form of modal window showed ->
> checkbox become unchecked.
> PS : if I uncheck my checkbox manually and retry, it's works.
> I include this this project in the mail. You can launch it with: "mvn
clean
> compile jetty:run"
> Do you have any ideas. Thank you very much.
> Clément
>
> HelloWorld.java
> public class HelloWorld extends WebPage {
> private CheckBox checkbox;
> private ModalWindow modalWindow;
> @SuppressWarnings("serial")
> public HelloWorld() {
> Form<Object> form = new Form<Object>("form1");
> add(new AjaxLink<Object>("click") {
> @Override
> public void onClick(AjaxRequestTarget target) {
> modalWindow.show(target);
> }
> });
> checkbox = new CheckBox("checkbox", new Model<Boolean>(true));
> checkbox.add(new OnChangeAjaxBehavior() {
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> System.out.println("checkbox set to :"+checkbox.getModelObject());
> }
> });
> checkbox.setOutputMarkupId(true);
> modalWindow = new ModalWindow("modal");
> SubmitPanel panel = new SubmitPanel("content", checkbox, modalWindow);
> modalWindow.setContent(panel);
> form.add(checkbox);
> form.add(modalWindow);
> form.add(new AjaxButton("submitForm") {
> @Override
> protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> System.out.println("on submit checkbox is :"+checkbox.getModelObject());
> }
> });
> add(form);
> }
> }
>
> HelloWorld.html
> <html>
> <body>
> <form wicket:id="form1">
> <div wicket:id="modal"></div>
> <input type="checkbox" wicket:id="checkbox" />
> <input type="submit" wicket:id="submitForm" />
> </form>
> <a wicket:id="click">click</a>
> </body>
> </html>
>
> SubmitPanel.java
> public class SubmitPanel extends Panel{
> public SubmitPanel(String id, final CheckBox checkbox, final ModalWindow
> modalWindow) {
> super(id);
> Form<Object> form =new Form<Object>("form2");
> form.add(new AjaxButton("submitForm2") {
> @Override
> protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> checkbox.setModelObject(true);
> target.addComponent(checkbox);
> modalWindow.close(target);
> }
> });
> add(form);
> }
> }
>
> SubmitPanel.html
> <wicket:panel>
> <form wicket:id="form2">
> <input type="submit" wicket:id="submitForm2" />
> </form>
> </wicket:panel>
>
>
>
> ---------------------------------------------------------------------
> 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




-- 
Pedro Henrique Oliveira dos Santos

Re: wicket nested form and modal

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Here is a workaround
http://www.mail-archive.com/users@wicket.apache.org/msg35946.html

**
Martin

2011/1/24 Clément Tamisier <cl...@gmail.com>:
> Hi, I have something strange with wicket 1.4 and I don't find what.
> I have 2 nested forms. The inner form (form2) is in a modal window, and when
> I validate this form (form2) the checkbox of "main" form (form1) become
> unchecked (which is initially checked).
> to test: click on "click" and submit the form of modal window showed ->
> checkbox become unchecked.
> PS : if I uncheck my checkbox manually and retry, it's works.
> I include this this project in the mail. You can launch it with: "mvn clean
> compile jetty:run"
> Do you have any ideas. Thank you very much.
> Clément
>
> HelloWorld.java
> public class HelloWorld extends WebPage {
> private CheckBox checkbox;
> private ModalWindow modalWindow;
> @SuppressWarnings("serial")
> public HelloWorld() {
> Form<Object> form = new Form<Object>("form1");
> add(new AjaxLink<Object>("click") {
> @Override
> public void onClick(AjaxRequestTarget target) {
> modalWindow.show(target);
> }
> });
> checkbox = new CheckBox("checkbox", new Model<Boolean>(true));
> checkbox.add(new OnChangeAjaxBehavior() {
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> System.out.println("checkbox set to :"+checkbox.getModelObject());
> }
> });
> checkbox.setOutputMarkupId(true);
> modalWindow = new ModalWindow("modal");
> SubmitPanel panel = new SubmitPanel("content", checkbox, modalWindow);
> modalWindow.setContent(panel);
> form.add(checkbox);
> form.add(modalWindow);
> form.add(new AjaxButton("submitForm") {
> @Override
> protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> System.out.println("on submit checkbox is :"+checkbox.getModelObject());
> }
> });
> add(form);
> }
> }
>
> HelloWorld.html
> <html>
> <body>
> <form wicket:id="form1">
> <div wicket:id="modal"></div>
> <input type="checkbox" wicket:id="checkbox" />
> <input type="submit" wicket:id="submitForm" />
> </form>
> <a wicket:id="click">click</a>
> </body>
> </html>
>
> SubmitPanel.java
> public class SubmitPanel extends Panel{
> public SubmitPanel(String id, final CheckBox checkbox, final ModalWindow
> modalWindow) {
> super(id);
> Form<Object> form =new Form<Object>("form2");
> form.add(new AjaxButton("submitForm2") {
> @Override
> protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> checkbox.setModelObject(true);
> target.addComponent(checkbox);
> modalWindow.close(target);
> }
> });
> add(form);
> }
> }
>
> SubmitPanel.html
> <wicket:panel>
> <form wicket:id="form2">
> <input type="submit" wicket:id="submitForm2" />
> </form>
> </wicket:panel>
>
>
>
> ---------------------------------------------------------------------
> 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