You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kurt Heston <kh...@hestonsystems.com> on 2009/03/07 21:26:24 UTC
warn user a field has changed
I haven't been able to make this work since my upgrade from 1.2.x to 1.3.5:
http://javathoughts.capesugarbird.com/2007/11/warning-on-page-exit-for-wicket-12x.html
It was pretty slick. I was able to warn the user that she/he had
changed a field without saving when trying to navigate away. Is there a
better facility in 1.3.x that I can use for the same purpose?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: warn user a field has changed
Posted by Kurt Heston <kh...@hestonsystems.com>.
Problem solved.
I had both <wicket:head> and <head> sections in my html and the
FormModificationDetectorBehavior was being attached twice. This was
causing a "too many recursions" error in the javascript and the code was
dying. Pulling out the <head> tag and placing everything within
<wicket:head> cured it.
It's working again.
Kurt Heston wrote:
> The problem appears to be related to the code I used to replace the
> old onAttach code. It was:
>
> ////////////////////
> protected void onAttach() {
> super.onAttach();
> if (firstTimeThru) {
> final WebMarkupContainer c =
> this.getBodyContainer().getBodyContainer();
> c.add(new SimpleAttributeModifier("onload",
> "FORMCONFIRM=true;FORMISDIRTY=false;"));
> c.add(new SimpleAttributeModifier("class", "body1"));
> c.add(new SimpleAttributeModifier("onbeforeunload",
> "return warnOnPageExit('Data has changed. Make sure you press
> save "
> + "if you want to keep your changes!');"));
> firstTimeThru = false;
> }
> }
> ////////////////////
>
> now it is:
>
> ////////////////////
> public void renderHead(IHeaderResponse arg0) {
>
> if (firstTimeThru) {
> arg0.renderOnLoadJavascript("FORMCONFIRM=true;FORMISDIRTY=false;");
> arg0.renderCSSReference("body1");
> arg0.renderOnEventJavacript("window", "onbeforeunload",
> "return warnOnPageExit('Data has changed. Make sure you press
> save "
> + "if you want to keep your changes!');");
> firstTimeThru = false;
> }
> }
>
> ////////////////////
>
> I'm focusing on tweaking this at the moment. Not sure yet what's
> going on.
>
> Kurt Heston wrote:
>> Not yet. Still trying to figure it out. Just wanted to make sure I
>> wasn't overlooking something in the manual that works just as as well
>> or better.
>>
>> Igor Vaynberg wrote:
>>> do you know why it doesnt work?
>>>
>>> -igor
>>>
>>> On Sat, Mar 7, 2009 at 12:26 PM, Kurt Heston
>>> <kh...@hestonsystems.com> wrote:
>>>
>>>> I haven't been able to make this work since my upgrade from 1.2.x
>>>> to 1.3.5:
>>>>
>>>> http://javathoughts.capesugarbird.com/2007/11/warning-on-page-exit-for-wicket-12x.html
>>>>
>>>>
>>>>
>>>> It was pretty slick. I was able to warn the user that she/he had
>>>> changed a field without saving when trying to navigate away. Is
>>>> there a
>>>> better facility in 1.3.x that I can use for the same purpose?
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: warn user a field has changed
Posted by Kurt Heston <kh...@hestonsystems.com>.
The problem appears to be related to the code I used to replace the old
onAttach code. It was:
////////////////////
protected void onAttach() {
super.onAttach();
if (firstTimeThru) {
final WebMarkupContainer c =
this.getBodyContainer().getBodyContainer();
c.add(new SimpleAttributeModifier("onload",
"FORMCONFIRM=true;FORMISDIRTY=false;"));
c.add(new SimpleAttributeModifier("class", "body1"));
c.add(new SimpleAttributeModifier("onbeforeunload",
"return warnOnPageExit('Data has changed. Make sure you press
save "
+ "if you want to keep your changes!');"));
firstTimeThru = false;
}
}
////////////////////
now it is:
////////////////////
public void renderHead(IHeaderResponse arg0) {
if (firstTimeThru) {
arg0.renderOnLoadJavascript("FORMCONFIRM=true;FORMISDIRTY=false;");
arg0.renderCSSReference("body1");
arg0.renderOnEventJavacript("window", "onbeforeunload",
"return warnOnPageExit('Data has changed. Make sure you press
save "
+ "if you want to keep your changes!');");
firstTimeThru = false;
}
}
////////////////////
I'm focusing on tweaking this at the moment. Not sure yet what's going on.
Kurt Heston wrote:
> Not yet. Still trying to figure it out. Just wanted to make sure I
> wasn't overlooking something in the manual that works just as as well
> or better.
>
> Igor Vaynberg wrote:
>> do you know why it doesnt work?
>>
>> -igor
>>
>> On Sat, Mar 7, 2009 at 12:26 PM, Kurt Heston
>> <kh...@hestonsystems.com> wrote:
>>
>>> I haven't been able to make this work since my upgrade from 1.2.x to
>>> 1.3.5:
>>>
>>> http://javathoughts.capesugarbird.com/2007/11/warning-on-page-exit-for-wicket-12x.html
>>>
>>>
>>>
>>> It was pretty slick. I was able to warn the user that she/he had
>>> changed a field without saving when trying to navigate away. Is
>>> there a
>>> better facility in 1.3.x that I can use for the same purpose?
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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
Re: warn user a field has changed
Posted by Kurt Heston <kh...@hestonsystems.com>.
Not yet. Still trying to figure it out. Just wanted to make sure I
wasn't overlooking something in the manual that works just as as well or
better.
Igor Vaynberg wrote:
> do you know why it doesnt work?
>
> -igor
>
> On Sat, Mar 7, 2009 at 12:26 PM, Kurt Heston <kh...@hestonsystems.com> wrote:
>
>> I haven't been able to make this work since my upgrade from 1.2.x to 1.3.5:
>>
>> http://javathoughts.capesugarbird.com/2007/11/warning-on-page-exit-for-wicket-12x.html
>>
>>
>> It was pretty slick. I was able to warn the user that she/he had
>> changed a field without saving when trying to navigate away. Is there a
>> better facility in 1.3.x that I can use for the same purpose?
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: warn user a field has changed
Posted by Igor Vaynberg <ig...@gmail.com>.
do you know why it doesnt work?
-igor
On Sat, Mar 7, 2009 at 12:26 PM, Kurt Heston <kh...@hestonsystems.com> wrote:
> I haven't been able to make this work since my upgrade from 1.2.x to 1.3.5:
>
> http://javathoughts.capesugarbird.com/2007/11/warning-on-page-exit-for-wicket-12x.html
>
>
> It was pretty slick. I was able to warn the user that she/he had
> changed a field without saving when trying to navigate away. Is there a
> better facility in 1.3.x that I can use for the same purpose?
>
>
> ---------------------------------------------------------------------
> 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