You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@mapshed.com.au> on 2012/08/20 04:41:27 UTC
datefield onchange
Hi all,
I've found the bug report: https://issues.apache.org/jira/browse/TAP5-1844
.. and am using tapestry 5.3.3 so the fix has been applied, however I
still can't get tapestry to call my 'onchange' handler.
<t:datefield value="dateValue" onchange="alert('here');" />
Is there some extra wiring required?
Thanks, Paul.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: datefield onchange
Posted by Paul Stanton <pa...@mapshed.com.au>.
It seems I have to combine a both approaches to achieve what I need -
whether or not this should be improved within the tapestry framework is
up for debate....
<t:datefield t:id="selectedDateElem" id="selectedDateElem"
onchange="alert('1 onchange attribute');" />
$("selectedDateElem").observe("change", function(event)
{
alert("2 change observer");
});
document.observe(Tapestry.FOCUS_CHANGE_EVENT, function(event)
{
if (Tapestry.currentFocusField &&
Tapestry.currentFocusField.id == "selectedDateElem")
alert("3 focus change observer");
});
Test Case 1:
User clicks into input field
user alters value of input field
user clicks out of input field
--> "1 onchange attribute" & "2 change observer"
Test case 2:
User clicks datepicker icon
user selects a new date from popup
--> "3 focus change observer"
So the onchange attribute is equivalent to the change observer,
therefore the only complete solution is to combine approaches 2 & 3:
$("selectedDateElem").observe("change", function(event)
{
Page.dateFieldChanged();
});
document.observe(Tapestry.FOCUS_CHANGE_EVENT, function(event)
{
if (Tapestry.currentFocusField &&
Tapestry.currentFocusField.id == "selectedDateElem")
Page.dateFieldChanged();
});
I think it would be nice if datefield, or tapestry's focus-change
handler would trigger the "change" event for the datefield's input, I
had assumed this was the point if jira 1844 ..
should I log a new jira to request this?
On 20/08/2012 11:49 PM, François Facon wrote:
> Hi Paul
>
> In 5.3 DatePicker (DateField.js) save informations in
> Tapestry.currentFocusField and fire the Tapestry.FOCUS_CHANGE_EVENT
> like this
> document.fire(Tapestry.FOCUS_CHANGE_EVENT, this.field);
>
> what about listen to tapestry:focuschange like the
> Tapestry.FieldEventManager (tapestry.js) do?
>
> document.observe("tapestry:focuschange", function(event)
> {
> if( Tapestry.currentFocusField!=undefined)
> alert(Tapestry.currentFocusField.id);
> });
>
> Regards
> François
>
> 2012/8/20, Paul Stanton <pa...@mapshed.com.au>:
>> Thanks brian, but i am assuming/hoping that the fix for issue 1844
>> allows me to do something a little more obvious.
>>
>> if not, i'm sure to use your solution.
>>
>> p.
>>
>> On 20/08/2012 9:16 PM, Bryan Lewis wrote:
>>> Ah yes, the problem of not catching changes made by clicking on the
>>> little
>>> calendar icon. Here's a crude work-around I'm using in 5.2.6, catching
>>> the
>>> click event.
>>>
>>> String scriptlet = "Event.observe('" + dateFieldId + "-trigger',
>>> 'click', function() { setChanged(true); });"
>>> javaScriptSupport.addScript(scriptlet);
>>>
>>> I wanted only to detect whether there'd been a change, to protect the
>>> user
>>> from leaving the page without saving. It's not perfect because the user
>>> might click the icon without actually making a change, but for my needs
>>> it's okay.
>>>
>>> I left a to-do note to myself a couple of years ago, "The fix might be to
>>> add an unload event on the form that checks whether any of the date
>>> values
>>> changed," but I don't know if that still makes sense.
>>>
>>>
>>> On Mon, Aug 20, 2012 at 6:34 AM, Paul Stanton <pa...@mapshed.com.au>
>>> wrote:
>>>
>>>> I've just tried that too howard,
>>>>
>>>> $("selectedDate").observe("**change", function(event)
>>>> {
>>>> alert('here');
>>>> });
>>>>
>>>> However this is only fired when you type into the input field and the
>>>> click out (blur) .. not when a date is selected via the popup
>>>> calendar...
>>>>
>>>> I have stepped through the js code via firebug and can see that the jira
>>>> 1844 patch is being executed, however my handler is never called...
>>>>
>>>> if someone could give me a little working eg that would be great!
>>>>
>>>> thanks.
>>>>
>>>>
>>>> On 20/08/2012 4:56 PM, Howard Lewis Ship wrote:
>>>>
>>>>> Have you tried observing the change event? The onchange attr may get
>>>>> overwritten by the date field JS.
>>>>>
>>>>> On Sunday, August 19, 2012, Paul Stanton wrote:
>>>>>
>>>>> Hi all,
>>>>>> I've found the bug report: https://issues.apache.org/**
>>>>>> jira/browse/TAP5-1844
>>>>>> <https://issues.apache.org/**jira/browse/TAP5-1844<https://issues.apache.org/jira/browse/TAP5-1844>
>>>>>> .. and am using tapestry 5.3.3 so the fix has been applied, however I
>>>>>> still can't get tapestry to call my 'onchange' handler.
>>>>>>
>>>>>> <t:datefield value="dateValue" onchange="alert('here');" />
>>>>>>
>>>>>> Is there some extra wiring required?
>>>>>>
>>>>>> Thanks, Paul.
>>>>>>
>>>>>> ------------------------------****----------------------------**
>>>>>> --**---------
>>>>>> To unsubscribe, e-mail:
>>>>>> users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>> ------------------------------**------------------------------**---------
>>>>
>>>> To unsubscribe, e-mail:
>>>> users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: datefield onchange
Posted by François Facon <fr...@atos.net>.
Hi Paul
In 5.3 DatePicker (DateField.js) save informations in
Tapestry.currentFocusField and fire the Tapestry.FOCUS_CHANGE_EVENT
like this
document.fire(Tapestry.FOCUS_CHANGE_EVENT, this.field);
what about listen to tapestry:focuschange like the
Tapestry.FieldEventManager (tapestry.js) do?
document.observe("tapestry:focuschange", function(event)
{
if( Tapestry.currentFocusField!=undefined)
alert(Tapestry.currentFocusField.id);
});
Regards
François
2012/8/20, Paul Stanton <pa...@mapshed.com.au>:
> Thanks brian, but i am assuming/hoping that the fix for issue 1844
> allows me to do something a little more obvious.
>
> if not, i'm sure to use your solution.
>
> p.
>
> On 20/08/2012 9:16 PM, Bryan Lewis wrote:
>> Ah yes, the problem of not catching changes made by clicking on the
>> little
>> calendar icon. Here's a crude work-around I'm using in 5.2.6, catching
>> the
>> click event.
>>
>> String scriptlet = "Event.observe('" + dateFieldId + "-trigger',
>> 'click', function() { setChanged(true); });"
>> javaScriptSupport.addScript(scriptlet);
>>
>> I wanted only to detect whether there'd been a change, to protect the
>> user
>> from leaving the page without saving. It's not perfect because the user
>> might click the icon without actually making a change, but for my needs
>> it's okay.
>>
>> I left a to-do note to myself a couple of years ago, "The fix might be to
>> add an unload event on the form that checks whether any of the date
>> values
>> changed," but I don't know if that still makes sense.
>>
>>
>> On Mon, Aug 20, 2012 at 6:34 AM, Paul Stanton <pa...@mapshed.com.au>
>> wrote:
>>
>>> I've just tried that too howard,
>>>
>>> $("selectedDate").observe("**change", function(event)
>>> {
>>> alert('here');
>>> });
>>>
>>> However this is only fired when you type into the input field and the
>>> click out (blur) .. not when a date is selected via the popup
>>> calendar...
>>>
>>> I have stepped through the js code via firebug and can see that the jira
>>> 1844 patch is being executed, however my handler is never called...
>>>
>>> if someone could give me a little working eg that would be great!
>>>
>>> thanks.
>>>
>>>
>>> On 20/08/2012 4:56 PM, Howard Lewis Ship wrote:
>>>
>>>> Have you tried observing the change event? The onchange attr may get
>>>> overwritten by the date field JS.
>>>>
>>>> On Sunday, August 19, 2012, Paul Stanton wrote:
>>>>
>>>> Hi all,
>>>>> I've found the bug report: https://issues.apache.org/**
>>>>> jira/browse/TAP5-1844
>>>>> <https://issues.apache.org/**jira/browse/TAP5-1844<https://issues.apache.org/jira/browse/TAP5-1844>
>>>>> .. and am using tapestry 5.3.3 so the fix has been applied, however I
>>>>> still can't get tapestry to call my 'onchange' handler.
>>>>>
>>>>> <t:datefield value="dateValue" onchange="alert('here');" />
>>>>>
>>>>> Is there some extra wiring required?
>>>>>
>>>>> Thanks, Paul.
>>>>>
>>>>> ------------------------------****----------------------------**
>>>>> --**---------
>>>>> To unsubscribe, e-mail:
>>>>> users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>>
>>> ------------------------------**------------------------------**---------
>>>
>>> To unsubscribe, e-mail:
>>> users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: datefield onchange
Posted by Paul Stanton <pa...@mapshed.com.au>.
Thanks brian, but i am assuming/hoping that the fix for issue 1844
allows me to do something a little more obvious.
if not, i'm sure to use your solution.
p.
On 20/08/2012 9:16 PM, Bryan Lewis wrote:
> Ah yes, the problem of not catching changes made by clicking on the little
> calendar icon. Here's a crude work-around I'm using in 5.2.6, catching the
> click event.
>
> String scriptlet = "Event.observe('" + dateFieldId + "-trigger',
> 'click', function() { setChanged(true); });"
> javaScriptSupport.addScript(scriptlet);
>
> I wanted only to detect whether there'd been a change, to protect the user
> from leaving the page without saving. It's not perfect because the user
> might click the icon without actually making a change, but for my needs
> it's okay.
>
> I left a to-do note to myself a couple of years ago, "The fix might be to
> add an unload event on the form that checks whether any of the date values
> changed," but I don't know if that still makes sense.
>
>
> On Mon, Aug 20, 2012 at 6:34 AM, Paul Stanton <pa...@mapshed.com.au> wrote:
>
>> I've just tried that too howard,
>>
>> $("selectedDate").observe("**change", function(event)
>> {
>> alert('here');
>> });
>>
>> However this is only fired when you type into the input field and the
>> click out (blur) .. not when a date is selected via the popup calendar...
>>
>> I have stepped through the js code via firebug and can see that the jira
>> 1844 patch is being executed, however my handler is never called...
>>
>> if someone could give me a little working eg that would be great!
>>
>> thanks.
>>
>>
>> On 20/08/2012 4:56 PM, Howard Lewis Ship wrote:
>>
>>> Have you tried observing the change event? The onchange attr may get
>>> overwritten by the date field JS.
>>>
>>> On Sunday, August 19, 2012, Paul Stanton wrote:
>>>
>>> Hi all,
>>>> I've found the bug report: https://issues.apache.org/**
>>>> jira/browse/TAP5-1844 <https://issues.apache.org/**jira/browse/TAP5-1844<https://issues.apache.org/jira/browse/TAP5-1844>
>>>> .. and am using tapestry 5.3.3 so the fix has been applied, however I
>>>> still can't get tapestry to call my 'onchange' handler.
>>>>
>>>> <t:datefield value="dateValue" onchange="alert('here');" />
>>>>
>>>> Is there some extra wiring required?
>>>>
>>>> Thanks, Paul.
>>>>
>>>> ------------------------------****----------------------------**
>>>> --**---------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>> ------------------------------**------------------------------**---------
>>
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: datefield onchange
Posted by Bryan Lewis <jb...@gmail.com>.
Ah yes, the problem of not catching changes made by clicking on the little
calendar icon. Here's a crude work-around I'm using in 5.2.6, catching the
click event.
String scriptlet = "Event.observe('" + dateFieldId + "-trigger',
'click', function() { setChanged(true); });"
javaScriptSupport.addScript(scriptlet);
I wanted only to detect whether there'd been a change, to protect the user
from leaving the page without saving. It's not perfect because the user
might click the icon without actually making a change, but for my needs
it's okay.
I left a to-do note to myself a couple of years ago, "The fix might be to
add an unload event on the form that checks whether any of the date values
changed," but I don't know if that still makes sense.
On Mon, Aug 20, 2012 at 6:34 AM, Paul Stanton <pa...@mapshed.com.au> wrote:
> I've just tried that too howard,
>
> $("selectedDate").observe("**change", function(event)
> {
> alert('here');
> });
>
> However this is only fired when you type into the input field and the
> click out (blur) .. not when a date is selected via the popup calendar...
>
> I have stepped through the js code via firebug and can see that the jira
> 1844 patch is being executed, however my handler is never called...
>
> if someone could give me a little working eg that would be great!
>
> thanks.
>
>
> On 20/08/2012 4:56 PM, Howard Lewis Ship wrote:
>
>> Have you tried observing the change event? The onchange attr may get
>> overwritten by the date field JS.
>>
>> On Sunday, August 19, 2012, Paul Stanton wrote:
>>
>> Hi all,
>>>
>>> I've found the bug report: https://issues.apache.org/**
>>> jira/browse/TAP5-1844 <https://issues.apache.org/**jira/browse/TAP5-1844<https://issues.apache.org/jira/browse/TAP5-1844>
>>> >
>>>
>>> .. and am using tapestry 5.3.3 so the fix has been applied, however I
>>> still can't get tapestry to call my 'onchange' handler.
>>>
>>> <t:datefield value="dateValue" onchange="alert('here');" />
>>>
>>> Is there some extra wiring required?
>>>
>>> Thanks, Paul.
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>
> ------------------------------**------------------------------**---------
>
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: datefield onchange
Posted by Paul Stanton <pa...@mapshed.com.au>.
I've just tried that too howard,
$("selectedDate").observe("change", function(event)
{
alert('here');
});
However this is only fired when you type into the input field and the
click out (blur) .. not when a date is selected via the popup calendar...
I have stepped through the js code via firebug and can see that the jira
1844 patch is being executed, however my handler is never called...
if someone could give me a little working eg that would be great!
thanks.
On 20/08/2012 4:56 PM, Howard Lewis Ship wrote:
> Have you tried observing the change event? The onchange attr may get
> overwritten by the date field JS.
>
> On Sunday, August 19, 2012, Paul Stanton wrote:
>
>> Hi all,
>>
>> I've found the bug report: https://issues.apache.org/**
>> jira/browse/TAP5-1844 <https://issues.apache.org/jira/browse/TAP5-1844>
>>
>> .. and am using tapestry 5.3.3 so the fix has been applied, however I
>> still can't get tapestry to call my 'onchange' handler.
>>
>> <t:datefield value="dateValue" onchange="alert('here');" />
>>
>> Is there some extra wiring required?
>>
>> Thanks, Paul.
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: datefield onchange
Posted by Howard Lewis Ship <hl...@gmail.com>.
Have you tried observing the change event? The onchange attr may get
overwritten by the date field JS.
On Sunday, August 19, 2012, Paul Stanton wrote:
> Hi all,
>
> I've found the bug report: https://issues.apache.org/**
> jira/browse/TAP5-1844 <https://issues.apache.org/jira/browse/TAP5-1844>
>
> .. and am using tapestry 5.3.3 so the fix has been applied, however I
> still can't get tapestry to call my 'onchange' handler.
>
> <t:datefield value="dateValue" onchange="alert('here');" />
>
> Is there some extra wiring required?
>
> Thanks, Paul.
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com