You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Boris Goldowsky <bg...@cast.org> on 2014/02/10 16:56:52 UTC

How to implement an auto-save behavior

I’m attempting to migrate an auto-saving behavior from wicket 1.5 to wicket 6.  In wicket 1.5 it worked by doing something like this every 30 seconds to loop through auto-save-enabled forms on the page and submit them:

 $("form.ajaxAutoSave").each(function() { 
  var form = $(this); 
  wicketSubmitFormById(form.attr('id')...) 
} 

The AJAX migration documentation - https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax - suggests replacing Wicket.submitFormById with Wicket.Ajax.submitForm , but this method does not appear to exist:  replacing the above code with

 $("form.ajaxAutoSave").each(function() { 
  var form = $(this); 
  //unsure of expected params so just picked one from the migration documentation 
  Wicket.Ajax.submitForm({"f":form.attr('id')}); 
} 

When the function is called I can see the following error in the console: 

Uncaught TypeError: Object # has no method 'submitForm' 

So I went into the console and I can see that Wicket.Ajax is defined, but Wicket.Ajax.submitForm is not.   

Is the documentation incorrect here, or is there some additional step to take to gain access to the submitForm method?

Alternatively - is there a better way to create an auto-save behavior?  AjaxFormSubmitBehavior would appear to almost meet the need, if there is a way to  tie it to a timer-generated event.

Boris


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


Re: How to implement an auto-save behavior

Posted by Boris Goldowsky <bg...@cast.org>.
Thank you Martin, that works like a charm.

Boris


On Feb 10, 2014, at 2:27 PM, Martin Grigorov <mg...@apache.org> wrote:

> Hi,
> 
> To submit a form all you need to provide to the object you pass to
> Wicket.Ajax.ajax() is the 'f' attribute:
> Wicket.Ajax.post({ u: 'url/to/AjaxFormSubmitBehavior', f: 'formId', sc:
> 'optionalSubmittingComponentId'});
> 
> I will update the Ajax chapter in the Reference guide soon to explain the
> JS API.
> 
> Martin Grigorov
> Wicket Training and Consulting
> 
> 
> On Mon, Feb 10, 2014 at 5:48 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
> 
>> Is not a function? If I look at the source code I see something like
>> 
>> submitMultipartForm = function(context) {
>> 
>> },
>> 
>> 
>> 
>> 
>> On Mon, Feb 10, 2014 at 5:41 PM, Boris Goldowsky <bgoldowsky@cast.org
>>> wrote:
>> 
>>> Thanks, but that also results in "Wicket.Ajax.Call.submitMultipartForm is
>>> not a function".
>>> 
>>> I suspect the answer is to get the parameters set up correctly and then
>>> arrange for the result of getCallbackScript() to be called periodically.
>>> If someone else has done something like this and has a working example
>>> that would be really helpful.
>>> 
>>> Boris
>>> 
>>> 
>>> 
>>> On Feb 10, 2014, at 11:08 AM, Ernesto Reinaldo Barreiro <
>>> reiern70@gmail.com> wrote:
>>> 
>>>> Maybe Wicket.Ajax.Call.subitMultipartForm?
>>>> 
>>>> 
>>>> On Mon, Feb 10, 2014 at 4:56 PM, Boris Goldowsky <bgoldowsky@cast.org
>>>> wrote:
>>>> 
>>>>> I'm attempting to migrate an auto-saving behavior from wicket 1.5 to
>>>>> wicket 6.  In wicket 1.5 it worked by doing something like this every
>> 30
>>>>> seconds to loop through auto-save-enabled forms on the page and submit
>>> them:
>>>>> 
>>>>> $("form.ajaxAutoSave").each(function() {
>>>>> var form = $(this);
>>>>> wicketSubmitFormById(form.attr('id')...)
>>>>> }
>>>>> 
>>>>> The AJAX migration documentation -
>>>>> https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax -
>>> suggests
>>>>> replacing Wicket.submitFormById with Wicket.Ajax.submitForm , but this
>>>>> method does not appear to exist:  replacing the above code with
>>>>> 
>>>>> $("form.ajaxAutoSave").each(function() {
>>>>> var form = $(this);
>>>>> //unsure of expected params so just picked one from the migration
>>>>> documentation
>>>>> Wicket.Ajax.submitForm({"f":form.attr('id')});
>>>>> }
>>>>> 
>>>>> When the function is called I can see the following error in the
>>> console:
>>>>> 
>>>>> Uncaught TypeError: Object # has no method 'submitForm'
>>>>> 
>>>>> So I went into the console and I can see that Wicket.Ajax is defined,
>>> but
>>>>> Wicket.Ajax.submitForm is not.
>>>>> 
>>>>> Is the documentation incorrect here, or is there some additional step
>> to
>>>>> take to gain access to the submitForm method?
>>>>> 
>>>>> Alternatively - is there a better way to create an auto-save behavior?
>>>>> AjaxFormSubmitBehavior would appear to almost meet the need, if there
>>> is a
>>>>> way to  tie it to a timer-generated event.
>>>>> 
>>>>> Boris
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> --
>>>> Regards - Ernesto Reinaldo Barreiro
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>>> 
>> 
>> 
>> --
>> Regards - Ernesto Reinaldo Barreiro
>> 


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


Re: How to implement an auto-save behavior

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

To submit a form all you need to provide to the object you pass to
Wicket.Ajax.ajax() is the 'f' attribute:
Wicket.Ajax.post({ u: 'url/to/AjaxFormSubmitBehavior', f: 'formId', sc:
'optionalSubmittingComponentId'});

I will update the Ajax chapter in the Reference guide soon to explain the
JS API.

Martin Grigorov
Wicket Training and Consulting


On Mon, Feb 10, 2014 at 5:48 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Is not a function? If I look at the source code I see something like
>
> submitMultipartForm = function(context) {
>
> },
>
>
>
>
> On Mon, Feb 10, 2014 at 5:41 PM, Boris Goldowsky <bgoldowsky@cast.org
> >wrote:
>
> > Thanks, but that also results in "Wicket.Ajax.Call.submitMultipartForm is
> > not a function".
> >
> > I suspect the answer is to get the parameters set up correctly and then
> > arrange for the result of getCallbackScript() to be called periodically.
> >  If someone else has done something like this and has a working example
> > that would be really helpful.
> >
> > Boris
> >
> >
> >
> > On Feb 10, 2014, at 11:08 AM, Ernesto Reinaldo Barreiro <
> > reiern70@gmail.com> wrote:
> >
> > > Maybe Wicket.Ajax.Call.subitMultipartForm?
> > >
> > >
> > > On Mon, Feb 10, 2014 at 4:56 PM, Boris Goldowsky <bgoldowsky@cast.org
> > >wrote:
> > >
> > >> I'm attempting to migrate an auto-saving behavior from wicket 1.5 to
> > >> wicket 6.  In wicket 1.5 it worked by doing something like this every
> 30
> > >> seconds to loop through auto-save-enabled forms on the page and submit
> > them:
> > >>
> > >> $("form.ajaxAutoSave").each(function() {
> > >>  var form = $(this);
> > >>  wicketSubmitFormById(form.attr('id')...)
> > >> }
> > >>
> > >> The AJAX migration documentation -
> > >> https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax -
> > suggests
> > >> replacing Wicket.submitFormById with Wicket.Ajax.submitForm , but this
> > >> method does not appear to exist:  replacing the above code with
> > >>
> > >> $("form.ajaxAutoSave").each(function() {
> > >>  var form = $(this);
> > >>  //unsure of expected params so just picked one from the migration
> > >> documentation
> > >>  Wicket.Ajax.submitForm({"f":form.attr('id')});
> > >> }
> > >>
> > >> When the function is called I can see the following error in the
> > console:
> > >>
> > >> Uncaught TypeError: Object # has no method 'submitForm'
> > >>
> > >> So I went into the console and I can see that Wicket.Ajax is defined,
> > but
> > >> Wicket.Ajax.submitForm is not.
> > >>
> > >> Is the documentation incorrect here, or is there some additional step
> to
> > >> take to gain access to the submitForm method?
> > >>
> > >> Alternatively - is there a better way to create an auto-save behavior?
> > >> AjaxFormSubmitBehavior would appear to almost meet the need, if there
> > is a
> > >> way to  tie it to a timer-generated event.
> > >>
> > >> Boris
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >>
> > >
> > >
> > > --
> > > Regards - Ernesto Reinaldo Barreiro
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>

Re: How to implement an auto-save behavior

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Is not a function? If I look at the source code I see something like

submitMultipartForm = function(context) {

},




On Mon, Feb 10, 2014 at 5:41 PM, Boris Goldowsky <bg...@cast.org>wrote:

> Thanks, but that also results in "Wicket.Ajax.Call.submitMultipartForm is
> not a function".
>
> I suspect the answer is to get the parameters set up correctly and then
> arrange for the result of getCallbackScript() to be called periodically.
>  If someone else has done something like this and has a working example
> that would be really helpful.
>
> Boris
>
>
>
> On Feb 10, 2014, at 11:08 AM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
> > Maybe Wicket.Ajax.Call.subitMultipartForm?
> >
> >
> > On Mon, Feb 10, 2014 at 4:56 PM, Boris Goldowsky <bgoldowsky@cast.org
> >wrote:
> >
> >> I'm attempting to migrate an auto-saving behavior from wicket 1.5 to
> >> wicket 6.  In wicket 1.5 it worked by doing something like this every 30
> >> seconds to loop through auto-save-enabled forms on the page and submit
> them:
> >>
> >> $("form.ajaxAutoSave").each(function() {
> >>  var form = $(this);
> >>  wicketSubmitFormById(form.attr('id')...)
> >> }
> >>
> >> The AJAX migration documentation -
> >> https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax -
> suggests
> >> replacing Wicket.submitFormById with Wicket.Ajax.submitForm , but this
> >> method does not appear to exist:  replacing the above code with
> >>
> >> $("form.ajaxAutoSave").each(function() {
> >>  var form = $(this);
> >>  //unsure of expected params so just picked one from the migration
> >> documentation
> >>  Wicket.Ajax.submitForm({"f":form.attr('id')});
> >> }
> >>
> >> When the function is called I can see the following error in the
> console:
> >>
> >> Uncaught TypeError: Object # has no method 'submitForm'
> >>
> >> So I went into the console and I can see that Wicket.Ajax is defined,
> but
> >> Wicket.Ajax.submitForm is not.
> >>
> >> Is the documentation incorrect here, or is there some additional step to
> >> take to gain access to the submitForm method?
> >>
> >> Alternatively - is there a better way to create an auto-save behavior?
> >> AjaxFormSubmitBehavior would appear to almost meet the need, if there
> is a
> >> way to  tie it to a timer-generated event.
> >>
> >> Boris
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: How to implement an auto-save behavior

Posted by Boris Goldowsky <bg...@cast.org>.
Thanks, but that also results in "Wicket.Ajax.Call.submitMultipartForm is not a function”.

I suspect the answer is to get the parameters set up correctly and then arrange for the result of getCallbackScript() to be called periodically.  If someone else has done something like this and has a working example that would be really helpful.

Boris



On Feb 10, 2014, at 11:08 AM, Ernesto Reinaldo Barreiro <re...@gmail.com> wrote:

> Maybe Wicket.Ajax.Call.subitMultipartForm?
> 
> 
> On Mon, Feb 10, 2014 at 4:56 PM, Boris Goldowsky <bg...@cast.org>wrote:
> 
>> I'm attempting to migrate an auto-saving behavior from wicket 1.5 to
>> wicket 6.  In wicket 1.5 it worked by doing something like this every 30
>> seconds to loop through auto-save-enabled forms on the page and submit them:
>> 
>> $("form.ajaxAutoSave").each(function() {
>>  var form = $(this);
>>  wicketSubmitFormById(form.attr('id')...)
>> }
>> 
>> The AJAX migration documentation -
>> https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax - suggests
>> replacing Wicket.submitFormById with Wicket.Ajax.submitForm , but this
>> method does not appear to exist:  replacing the above code with
>> 
>> $("form.ajaxAutoSave").each(function() {
>>  var form = $(this);
>>  //unsure of expected params so just picked one from the migration
>> documentation
>>  Wicket.Ajax.submitForm({"f":form.attr('id')});
>> }
>> 
>> When the function is called I can see the following error in the console:
>> 
>> Uncaught TypeError: Object # has no method 'submitForm'
>> 
>> So I went into the console and I can see that Wicket.Ajax is defined, but
>> Wicket.Ajax.submitForm is not.
>> 
>> Is the documentation incorrect here, or is there some additional step to
>> take to gain access to the submitForm method?
>> 
>> Alternatively - is there a better way to create an auto-save behavior?
>> AjaxFormSubmitBehavior would appear to almost meet the need, if there is a
>> way to  tie it to a timer-generated event.
>> 
>> Boris
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
> 
> 
> -- 
> Regards - Ernesto Reinaldo Barreiro


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


Re: How to implement an auto-save behavior

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Maybe Wicket.Ajax.Call.subitMultipartForm?


On Mon, Feb 10, 2014 at 4:56 PM, Boris Goldowsky <bg...@cast.org>wrote:

> I'm attempting to migrate an auto-saving behavior from wicket 1.5 to
> wicket 6.  In wicket 1.5 it worked by doing something like this every 30
> seconds to loop through auto-save-enabled forms on the page and submit them:
>
>  $("form.ajaxAutoSave").each(function() {
>   var form = $(this);
>   wicketSubmitFormById(form.attr('id')...)
> }
>
> The AJAX migration documentation -
> https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax - suggests
> replacing Wicket.submitFormById with Wicket.Ajax.submitForm , but this
> method does not appear to exist:  replacing the above code with
>
>  $("form.ajaxAutoSave").each(function() {
>   var form = $(this);
>   //unsure of expected params so just picked one from the migration
> documentation
>   Wicket.Ajax.submitForm({"f":form.attr('id')});
> }
>
> When the function is called I can see the following error in the console:
>
> Uncaught TypeError: Object # has no method 'submitForm'
>
> So I went into the console and I can see that Wicket.Ajax is defined, but
> Wicket.Ajax.submitForm is not.
>
> Is the documentation incorrect here, or is there some additional step to
> take to gain access to the submitForm method?
>
> Alternatively - is there a better way to create an auto-save behavior?
>  AjaxFormSubmitBehavior would appear to almost meet the need, if there is a
> way to  tie it to a timer-generated event.
>
> Boris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro