<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Setting a custom label function on a Flex DateField control</title>
	<atom:link href="http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Brixel</title>
		<link>http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/comment-page-1/#comment-2119</link>
		<dc:creator>Brixel</dc:creator>
		<pubDate>Fri, 02 May 2008 21:44:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-2119</guid>
		<description>Peter,

That sort of works, but there are a few issues with that solution.

1. It assumes you have only one DateField, it would be nice to create a generic pareseFunction. Seems like it should have a reference to whom is issuing the command, maybe an enhancement?

2. The selectedDate it returns to the control isn&#039;t always what the user began with before typing. Let&#039;s say for example that your control starts with todays date &quot;05/02/2008&quot;. Then you start typing a new &quot;days&quot; value of 46, which would be invalid, but as your typing the parseFunciton is firing and returning a date on each key stroke, so the last known good date becomes &quot;05/04/2008&quot; instead of what the user started with before attempting to make a change.

I&#039;m not sure there is a good way to handle issue 2 outside of storing the date when the control receives focus, and setting it back to that value on error.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>That sort of works, but there are a few issues with that solution.</p>
<p>1. It assumes you have only one DateField, it would be nice to create a generic pareseFunction. Seems like it should have a reference to whom is issuing the command, maybe an enhancement?</p>
<p>2. The selectedDate it returns to the control isn&#8217;t always what the user began with before typing. Let&#8217;s say for example that your control starts with todays date &#8220;05/02/2008&#8243;. Then you start typing a new &#8220;days&#8221; value of 46, which would be invalid, but as your typing the parseFunciton is firing and returning a date on each key stroke, so the last known good date becomes &#8220;05/04/2008&#8243; instead of what the user started with before attempting to make a change.</p>
<p>I&#8217;m not sure there is a good way to handle issue 2 outside of storing the date when the control receives focus, and setting it back to that value on error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/comment-page-1/#comment-2118</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Fri, 02 May 2008 14:27:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-2118</guid>
		<description>&lt;a href=&quot;http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-12435&quot; rel=&quot;nofollow&quot;&gt;Brixel&lt;/a&gt;,

Great, thanks! It looks like you already have a workaround, but this should also &quot;fix&quot; the issue.
&lt;pre class=&quot;code&quot;&gt;
private function ParseFunction( valueString:String, inputFormat:String ):Date
{
	var dateStr:String = dateFormat.format( valueString );
	var d:Date = new Date( dateStr );
	if ( dateFormat.error &#124;&#124; isNaN( d.time ) ) {
		return dateField.selectedDate;
	}
	return d;
}
&lt;/pre&gt;

Let me know if that works and we can update the bug with the workaround/solution.

Thanks,
Peter</description>
		<content:encoded><![CDATA[<p><a href="http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-12435" rel="nofollow">Brixel</a>,</p>
<p>Great, thanks! It looks like you already have a workaround, but this should also &#8220;fix&#8221; the issue.</p>
<pre class="code">
private function ParseFunction( valueString:String, inputFormat:String ):Date
{
	var dateStr:String = dateFormat.format( valueString );
	var d:Date = new Date( dateStr );
	if ( dateFormat.error || isNaN( d.time ) ) {
		return dateField.selectedDate;
	}
	return d;
}
</pre>
<p>Let me know if that works and we can update the bug with the workaround/solution.</p>
<p>Thanks,<br />
Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brixel</title>
		<link>http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/comment-page-1/#comment-2117</link>
		<dc:creator>Brixel</dc:creator>
		<pubDate>Fri, 02 May 2008 11:20:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-2117</guid>
		<description>Peter,

I&#039;ve created https://bugs.adobe.com/jira/browse/SDK-15448 with an attached sample.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I&#8217;ve created <a href="https://bugs.adobe.com/jira/browse/SDK-15448" rel="nofollow">https://bugs.adobe.com/jira/browse/SDK-15448</a> with an attached sample.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/comment-page-1/#comment-2116</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Thu, 01 May 2008 20:12:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-2116</guid>
		<description>&lt;a href=&quot;http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-12426&quot; rel=&quot;nofollow&quot;&gt;Brixel&lt;/a&gt;,

Can you file a bug at http://bugs.adobe.com/flex/ and post the bug number here so a few people here can vote and track the issue? Also, if you could attach a simple, reproducible test case to the bug report that would help a lot.

I&#039;ll try and play around with this later tonight when I get some time and see if I can find out what is going on.

Thanks,
Peter</description>
		<content:encoded><![CDATA[<p><a href="http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-12426" rel="nofollow">Brixel</a>,</p>
<p>Can you file a bug at <a href="http://bugs.adobe.com/flex/" rel="nofollow">http://bugs.adobe.com/flex/</a> and post the bug number here so a few people here can vote and track the issue? Also, if you could attach a simple, reproducible test case to the bug report that would help a lot.</p>
<p>I&#8217;ll try and play around with this later tonight when I get some time and see if I can find out what is going on.</p>
<p>Thanks,<br />
Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brixel</title>
		<link>http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/comment-page-1/#comment-2115</link>
		<dc:creator>Brixel</dc:creator>
		<pubDate>Thu, 01 May 2008 19:18:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/12/12/setting-a-custom-label-function-on-a-flex-datefield-control/#comment-2115</guid>
		<description>Peter,

I&#039;m having trouble when using the labelFunction and the DateField has editable set to true. I also have a parseFunction to handle the reverse of the labelFunction.

The problem comes not from using the date picker, but rather when typing in dates. If I type in a valid date then everything is fine. It&#039;s when I type in an invalid date, the parseFunction throws back a &quot;1/0/NaN&quot;.

I&#039;m cool with that, but what is escaping me is how to capture the fact that it&#039;s failed and just return null or the date that was previously selected. A try catch inside the parseFunction doesn&#039;t seem to work and the method only has the value and input format as parameters.

I&#039;ve also attempted to use the DateValidator, but it&#039;s having problems certain date formats in this scenario. There just don&#039;t seem to be any examples of using all of these controls together when you have a product that has to support multiple ( international ) date formats.

Really I&#039;m just looking for a way to use the labelFunction with an editable DateField ( formatString will not work for me because it doesn&#039;t support &quot;M/D/YYYY&quot; ), and on an incorrectly entered date, capture the failure and set the date back to what it was.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I&#8217;m having trouble when using the labelFunction and the DateField has editable set to true. I also have a parseFunction to handle the reverse of the labelFunction.</p>
<p>The problem comes not from using the date picker, but rather when typing in dates. If I type in a valid date then everything is fine. It&#8217;s when I type in an invalid date, the parseFunction throws back a &#8220;1/0/NaN&#8221;.</p>
<p>I&#8217;m cool with that, but what is escaping me is how to capture the fact that it&#8217;s failed and just return null or the date that was previously selected. A try catch inside the parseFunction doesn&#8217;t seem to work and the method only has the value and input format as parameters.</p>
<p>I&#8217;ve also attempted to use the DateValidator, but it&#8217;s having problems certain date formats in this scenario. There just don&#8217;t seem to be any examples of using all of these controls together when you have a product that has to support multiple ( international ) date formats.</p>
<p>Really I&#8217;m just looking for a way to use the labelFunction with an editable DateField ( formatString will not work for me because it doesn&#8217;t support &#8220;M/D/YYYY&#8221; ), and on an incorrectly entered date, capture the failure and set the date back to what it was.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

