Re: Preserving user input on ajax changes
I forgot to reply to this. Your observations are absolutely correct. I realized that I was using the ListView incorrectly, and recreating it on each refresh. No wonder I was losing my values. Now it works like a charm. Thanks. -Nelson On Mon, Jun 6, 2011 at 1:29 PM, Pedro Santos wrote: > Hi Nelson, ListView recreate its items every render, so it looses > their raw input. You can set reuse items flag - ListView.setReuseItems > and prevent this problem. Also notify the list view about changes in > the list to make it recreate its items by invoking ListView#removeAll > > Also you may want to read an article about this problem and another > solution: > http://wicketinaction.com/2008/10/building-a-listeditor-form-component/ > > About the rejected message, try to send the message as plain text > rather than HTML, it gives you a better span score. > > On Mon, Jun 6, 2011 at 5:06 PM, Nelson Segura wrote: >> I think that my problem is that I am not reusing the models/ recreating >> models on refresh. Is that a possible cause? >> >> I have ListView that display the data, and the list itself is dynamic, >> depending on what the users selects (that is the reason I need to refresh >> the whole form) >> I noticed input outside the ListView preserves the input, so It is very >> possible that is my problem. >> >> Should I try another type of repeater? I am looking at the refreshing view >> instead. >> >> (for some reason my previous two responses were rejected by the list server) >> >> -Nelson >> >> On Thu, Jun 2, 2011 at 7:23 PM, Igor Vaynberg >> wrote: >>> >>> default processing = false means do not validate, etc. but, inputs are >>> preserved. make sure your ajaxsubmitlink is inside the correct form. >>> you can specify one in its constructor. >>> >>> -igor >>> >>> On Thu, Jun 2, 2011 at 4:22 PM, Nelson Segura wrote: >>> > On the AjaxSubmitLink, correct? >>> > When I do that, the input of the other fields is lost (which has not been >>> > previously submitted). >>> > How does wicket exactly decides whether to show the model value or the >>> > user >>> > raw input? >>> > My Ajax links is refreshing the whole panel. >>> > -Nelson >>> > >>> > >>> > On Thu, Jun 2, 2011 at 4:14 PM, Igor Vaynberg >>> > wrote: >>> > >>> >> you want setDefaultFormProcessing(false) >>> >> >>> >> -igor >>> >> >>> >> On Thu, Jun 2, 2011 at 3:41 PM, Nelson Segura wrote: >>> >> > I have a form to which I need to add dynamic fields using ajax, >>> >> > whenever >>> >> the >>> >> > user clicks on the "add new input" link. >>> >> > I need to preserve the current user input, without actually updating >>> >> > the >>> >> > backing models (or at least preserve input that is not completely >>> >> > valid, >>> >> or >>> >> > do not show errors if the user as not entered a required field) >>> >> > >>> >> > I am using an AjaxSubmitLink to submit the current user input, but >>> >> > >>> >> > (a) I am not able to preserve the input (if I use >>> >> > setDefaultFormProcessing(true)) >>> >> > (b) I get validation errors, or lose invalid input if I try to mock >>> >> > with >>> >> the >>> >> > onError() method of the AjaxSubmitLink >>> >> > >>> >> > What is the correct way to do this? >>> >> > >>> >> > -Nelson >>> >> > >>> >> >>> >> - >>> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>> >> For additional commands, e-mail: users-h...@wicket.apache.org >>> >> >>> >> >>> > >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>> For additional commands, e-mail: users-h...@wicket.apache.org >>> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > > > > -- > Pedro Henrique Oliveira dos Santos > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Preserving user input on ajax changes
Hi Nelson, ListView recreate its items every render, so it looses their raw input. You can set reuse items flag - ListView.setReuseItems and prevent this problem. Also notify the list view about changes in the list to make it recreate its items by invoking ListView#removeAll Also you may want to read an article about this problem and another solution: http://wicketinaction.com/2008/10/building-a-listeditor-form-component/ About the rejected message, try to send the message as plain text rather than HTML, it gives you a better span score. On Mon, Jun 6, 2011 at 5:06 PM, Nelson Segura wrote: > I think that my problem is that I am not reusing the models/ recreating > models on refresh. Is that a possible cause? > > I have ListView that display the data, and the list itself is dynamic, > depending on what the users selects (that is the reason I need to refresh > the whole form) > I noticed input outside the ListView preserves the input, so It is very > possible that is my problem. > > Should I try another type of repeater? I am looking at the refreshing view > instead. > > (for some reason my previous two responses were rejected by the list server) > > -Nelson > > On Thu, Jun 2, 2011 at 7:23 PM, Igor Vaynberg wrote: >> >> default processing = false means do not validate, etc. but, inputs are >> preserved. make sure your ajaxsubmitlink is inside the correct form. >> you can specify one in its constructor. >> >> -igor >> >> On Thu, Jun 2, 2011 at 4:22 PM, Nelson Segura wrote: >> > On the AjaxSubmitLink, correct? >> > When I do that, the input of the other fields is lost (which has not been >> > previously submitted). >> > How does wicket exactly decides whether to show the model value or the user >> > raw input? >> > My Ajax links is refreshing the whole panel. >> > -Nelson >> > >> > >> > On Thu, Jun 2, 2011 at 4:14 PM, Igor Vaynberg >> > wrote: >> > >> >> you want setDefaultFormProcessing(false) >> >> >> >> -igor >> >> >> >> On Thu, Jun 2, 2011 at 3:41 PM, Nelson Segura wrote: >> >> > I have a form to which I need to add dynamic fields using ajax, whenever >> >> the >> >> > user clicks on the "add new input" link. >> >> > I need to preserve the current user input, without actually updating the >> >> > backing models (or at least preserve input that is not completely valid, >> >> or >> >> > do not show errors if the user as not entered a required field) >> >> > >> >> > I am using an AjaxSubmitLink to submit the current user input, but >> >> > >> >> > (a) I am not able to preserve the input (if I use >> >> > setDefaultFormProcessing(true)) >> >> > (b) I get validation errors, or lose invalid input if I try to mock with >> >> the >> >> > onError() method of the AjaxSubmitLink >> >> > >> >> > What is the correct way to do this? >> >> > >> >> > -Nelson >> >> > >> >> >> >> - >> >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> >> >> >> > >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Pedro Henrique Oliveira dos Santos - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Preserving user input on ajax changes
I think that my problem is that I am not reusing the models/ recreating models on refresh. Is that a possible cause? I have ListView that display the data, and the list itself is dynamic, depending on what the users selects (that is the reason I need to refresh the whole form) I noticed input outside the ListView preserves the input, so It is very possible that is my problem. Should I try another type of repeater? I am looking at the refreshing view instead. (for some reason my previous two responses were rejected by the list server) -Nelson On Thu, Jun 2, 2011 at 7:23 PM, Igor Vaynberg wrote: > > default processing = false means do not validate, etc. but, inputs are > preserved. make sure your ajaxsubmitlink is inside the correct form. > you can specify one in its constructor. > > -igor > > On Thu, Jun 2, 2011 at 4:22 PM, Nelson Segura wrote: > > On the AjaxSubmitLink, correct? > > When I do that, the input of the other fields is lost (which has not been > > previously submitted). > > How does wicket exactly decides whether to show the model value or the user > > raw input? > > My Ajax links is refreshing the whole panel. > > -Nelson > > > > > > On Thu, Jun 2, 2011 at 4:14 PM, Igor Vaynberg > > wrote: > > > >> you want setDefaultFormProcessing(false) > >> > >> -igor > >> > >> On Thu, Jun 2, 2011 at 3:41 PM, Nelson Segura wrote: > >> > I have a form to which I need to add dynamic fields using ajax, whenever > >> the > >> > user clicks on the "add new input" link. > >> > I need to preserve the current user input, without actually updating the > >> > backing models (or at least preserve input that is not completely valid, > >> or > >> > do not show errors if the user as not entered a required field) > >> > > >> > I am using an AjaxSubmitLink to submit the current user input, but > >> > > >> > (a) I am not able to preserve the input (if I use > >> > setDefaultFormProcessing(true)) > >> > (b) I get validation errors, or lose invalid input if I try to mock with > >> the > >> > onError() method of the AjaxSubmitLink > >> > > >> > What is the correct way to do this? > >> > > >> > -Nelson > >> > > >> > >> - > >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >> For additional commands, e-mail: users-h...@wicket.apache.org > >> > >> > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Preserving user input on ajax changes
default processing = false means do not validate, etc. but, inputs are preserved. make sure your ajaxsubmitlink is inside the correct form. you can specify one in its constructor. -igor On Thu, Jun 2, 2011 at 4:22 PM, Nelson Segura wrote: > On the AjaxSubmitLink, correct? > When I do that, the input of the other fields is lost (which has not been > previously submitted). > How does wicket exactly decides whether to show the model value or the user > raw input? > My Ajax links is refreshing the whole panel. > -Nelson > > > On Thu, Jun 2, 2011 at 4:14 PM, Igor Vaynberg wrote: > >> you want setDefaultFormProcessing(false) >> >> -igor >> >> On Thu, Jun 2, 2011 at 3:41 PM, Nelson Segura wrote: >> > I have a form to which I need to add dynamic fields using ajax, whenever >> the >> > user clicks on the "add new input" link. >> > I need to preserve the current user input, without actually updating the >> > backing models (or at least preserve input that is not completely valid, >> or >> > do not show errors if the user as not entered a required field) >> > >> > I am using an AjaxSubmitLink to submit the current user input, but >> > >> > (a) I am not able to preserve the input (if I use >> > setDefaultFormProcessing(true)) >> > (b) I get validation errors, or lose invalid input if I try to mock with >> the >> > onError() method of the AjaxSubmitLink >> > >> > What is the correct way to do this? >> > >> > -Nelson >> > >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Preserving user input on ajax changes
Hi Nelson, the raw input has preference and it remains in the form component until be converted and set in the form component model. For your use case you can use a simple AjaxLink targeting just the dynamic fields panel, not the whole form. On Thu, Jun 2, 2011 at 8:22 PM, Nelson Segura wrote: > On the AjaxSubmitLink, correct? > When I do that, the input of the other fields is lost (which has not been > previously submitted). > How does wicket exactly decides whether to show the model value or the user > raw input? > My Ajax links is refreshing the whole panel. > -Nelson > > > On Thu, Jun 2, 2011 at 4:14 PM, Igor Vaynberg wrote: > >> you want setDefaultFormProcessing(false) >> >> -igor >> >> On Thu, Jun 2, 2011 at 3:41 PM, Nelson Segura wrote: >> > I have a form to which I need to add dynamic fields using ajax, whenever >> the >> > user clicks on the "add new input" link. >> > I need to preserve the current user input, without actually updating the >> > backing models (or at least preserve input that is not completely valid, >> or >> > do not show errors if the user as not entered a required field) >> > >> > I am using an AjaxSubmitLink to submit the current user input, but >> > >> > (a) I am not able to preserve the input (if I use >> > setDefaultFormProcessing(true)) >> > (b) I get validation errors, or lose invalid input if I try to mock with >> the >> > onError() method of the AjaxSubmitLink >> > >> > What is the correct way to do this? >> > >> > -Nelson >> > >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > -- Pedro Henrique Oliveira dos Santos - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Preserving user input on ajax changes
On the AjaxSubmitLink, correct? When I do that, the input of the other fields is lost (which has not been previously submitted). How does wicket exactly decides whether to show the model value or the user raw input? My Ajax links is refreshing the whole panel. -Nelson On Thu, Jun 2, 2011 at 4:14 PM, Igor Vaynberg wrote: > you want setDefaultFormProcessing(false) > > -igor > > On Thu, Jun 2, 2011 at 3:41 PM, Nelson Segura wrote: > > I have a form to which I need to add dynamic fields using ajax, whenever > the > > user clicks on the "add new input" link. > > I need to preserve the current user input, without actually updating the > > backing models (or at least preserve input that is not completely valid, > or > > do not show errors if the user as not entered a required field) > > > > I am using an AjaxSubmitLink to submit the current user input, but > > > > (a) I am not able to preserve the input (if I use > > setDefaultFormProcessing(true)) > > (b) I get validation errors, or lose invalid input if I try to mock with > the > > onError() method of the AjaxSubmitLink > > > > What is the correct way to do this? > > > > -Nelson > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: Preserving user input on ajax changes
you want setDefaultFormProcessing(false) -igor On Thu, Jun 2, 2011 at 3:41 PM, Nelson Segura wrote: > I have a form to which I need to add dynamic fields using ajax, whenever the > user clicks on the "add new input" link. > I need to preserve the current user input, without actually updating the > backing models (or at least preserve input that is not completely valid, or > do not show errors if the user as not entered a required field) > > I am using an AjaxSubmitLink to submit the current user input, but > > (a) I am not able to preserve the input (if I use > setDefaultFormProcessing(true)) > (b) I get validation errors, or lose invalid input if I try to mock with the > onError() method of the AjaxSubmitLink > > What is the correct way to do this? > > -Nelson > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Preserving user input on ajax changes
I have a form to which I need to add dynamic fields using ajax, whenever the user clicks on the "add new input" link. I need to preserve the current user input, without actually updating the backing models (or at least preserve input that is not completely valid, or do not show errors if the user as not entered a required field) I am using an AjaxSubmitLink to submit the current user input, but (a) I am not able to preserve the input (if I use setDefaultFormProcessing(true)) (b) I get validation errors, or lose invalid input if I try to mock with the onError() method of the AjaxSubmitLink What is the correct way to do this? -Nelson