<?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: Multiple validators on a single component</title>
	<atom:link href="http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/</link>
	<description>Adobe Flex, Flash Platform and everything else about software development from a developer&#039;s point of view</description>
	<lastBuildDate>Thu, 02 Feb 2012 10:09:06 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Chris Gruel</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-10</link>
		<dc:creator>Chris Gruel</dc:creator>
		<pubDate>Thu, 31 Dec 2009 12:41:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-10</guid>
		<description>You are very welcome, I wouldn&#039;t have even thought of it if I hadn&#039;t come across your site so the thanks really belongs to you. The basic idea was all yours and I am grateful for your willingness to share. That is one of the things I love  the most about the Flex community, the openness of the developers all building an improving each-other&#039;s creations.</description>
		<content:encoded><![CDATA[<p>You are very welcome, I wouldn&#8217;t have even thought of it if I hadn&#8217;t come across your site so the thanks really belongs to you. The basic idea was all yours and I am grateful for your willingness to share. That is one of the things I love  the most about the Flex community, the openness of the developers all building an improving each-other&#8217;s creations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Bresolin</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-9</link>
		<dc:creator>Andrea Bresolin</dc:creator>
		<pubDate>Mon, 21 Dec 2009 22:50:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-9</guid>
		<description>I think I understand what you did. You&#039;ve got a main validator connected to the component that has to be validated through its source and property values. The only purpose of the main validator is to manage a set of different... let&#039;s call them child validators, that you pass to the main one through an array. When the main validator is required to validate the component, it loops through the array calling for each child validator its validate method and passing to it, as an argument, the value read from the source component through the specified property. You avoid setting source and property values for the child validators because you pass the value to validate directly to the validate method and you avoid having the child validators to interfere with the setting of the errorString of the component to validate. So the main validator can collect all the results from the validate method of the child validators and return a merged version as the only validation event for the component, thus allowing Flex to set the errorString as the union of all the validations. This is a really interesting approach. Thanks a lot Chris for taking the time to write your idea! Looking at something from a different point of view is always a good thing. Thanks.</description>
		<content:encoded><![CDATA[<p>I think I understand what you did. You&#8217;ve got a main validator connected to the component that has to be validated through its source and property values. The only purpose of the main validator is to manage a set of different&#8230; let&#8217;s call them child validators, that you pass to the main one through an array. When the main validator is required to validate the component, it loops through the array calling for each child validator its validate method and passing to it, as an argument, the value read from the source component through the specified property. You avoid setting source and property values for the child validators because you pass the value to validate directly to the validate method and you avoid having the child validators to interfere with the setting of the errorString of the component to validate. So the main validator can collect all the results from the validate method of the child validators and return a merged version as the only validation event for the component, thus allowing Flex to set the errorString as the union of all the validations. This is a really interesting approach. Thanks a lot Chris for taking the time to write your idea! Looking at something from a different point of view is always a good thing. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Gruel</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-8</link>
		<dc:creator>Chris Gruel</dc:creator>
		<pubDate>Sat, 19 Dec 2009 14:08:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-8</guid>
		<description>We have a need for declaration in MXML because we use validators within our datagrid columns using the Farata Systems Clear Toolkit giving us cell level on screen validations. After posting here last time I thought I would go give my idea a try. I was successful, unfortunately my company won&#039;t let me share source code created on the job but the implementation was so deceptively simple I figure I can describe it. My class has a public array so you just declare that array within the MXML declaration. Then you put n number of validators inside there, the trick is to not give them source or property information, only give that to the main validator. Then within the overridden doValidations method you loop through the validators giving them the main validator&#039;s value (the value from source) and capturing their validation result event failures and corresponding error messages. If you have gone through all of them and your capture list is empty then you have no errors, if any errors are found create a validation result with the combined error messages (minus duplicates if desired) to be returned and the desired effect is achieved. Using this method we can add n number of validators to a component and display valid or n number of errors in one.</description>
		<content:encoded><![CDATA[<p>We have a need for declaration in MXML because we use validators within our datagrid columns using the Farata Systems Clear Toolkit giving us cell level on screen validations. After posting here last time I thought I would go give my idea a try. I was successful, unfortunately my company won&#8217;t let me share source code created on the job but the implementation was so deceptively simple I figure I can describe it. My class has a public array so you just declare that array within the MXML declaration. Then you put n number of validators inside there, the trick is to not give them source or property information, only give that to the main validator. Then within the overridden doValidations method you loop through the validators giving them the main validator&#8217;s value (the value from source) and capturing their validation result event failures and corresponding error messages. If you have gone through all of them and your capture list is empty then you have no errors, if any errors are found create a validation result with the combined error messages (minus duplicates if desired) to be returned and the desired effect is achieved. Using this method we can add n number of validators to a component and display valid or n number of errors in one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Bresolin</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-7</link>
		<dc:creator>Andrea Bresolin</dc:creator>
		<pubDate>Thu, 17 Dec 2009 00:52:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-7</guid>
		<description>My main goal was to be able to use transparently all the existing Flex standard validators (like StringValidator, NumberValidator and so on) possibly together with my own validators. To achieve this, I couldn&#039;t extend the base Validator class (the standard validators still extend the base one in the SDK). Anyway, I think it would be difficult to obtain the same result extending only the base Validator class because the real problem is in the function validationResultHandler inside the UIComponent base class. That&#039;s where all the validation events dispatched by the validators are handled (in fact, the Validator instance adds the validationResultHandler function on its source instance as a listener for the validation events). The validationResultHandler function is the one that sets the errorString property of the validator&#039;s source so with the ComponentValidationManager I basically override the behavior of validationResultHandler setting my own errorString after it already set its own. To use the ComponentValidationManager directly inside MXML, I think it would be possible to modify it trying to manage the managedComponent and the managedValidators properties through setter functions and the commitProperties function to coordinate everything, instead of passing them only in the constructor of the class. I didn&#039;t investigate into this solution just because having multiple validators on a single component is not so common and I thought it was fine to just use this approach creating instances of the ComponentValidationManager in the script part, but it would be interesting to extend the versatility of the manager.</description>
		<content:encoded><![CDATA[<p>My main goal was to be able to use transparently all the existing Flex standard validators (like StringValidator, NumberValidator and so on) possibly together with my own validators. To achieve this, I couldn&#8217;t extend the base Validator class (the standard validators still extend the base one in the SDK). Anyway, I think it would be difficult to obtain the same result extending only the base Validator class because the real problem is in the function validationResultHandler inside the UIComponent base class. That&#8217;s where all the validation events dispatched by the validators are handled (in fact, the Validator instance adds the validationResultHandler function on its source instance as a listener for the validation events). The validationResultHandler function is the one that sets the errorString property of the validator&#8217;s source so with the ComponentValidationManager I basically override the behavior of validationResultHandler setting my own errorString after it already set its own. To use the ComponentValidationManager directly inside MXML, I think it would be possible to modify it trying to manage the managedComponent and the managedValidators properties through setter functions and the commitProperties function to coordinate everything, instead of passing them only in the constructor of the class. I didn&#8217;t investigate into this solution just because having multiple validators on a single component is not so common and I thought it was fine to just use this approach creating instances of the ComponentValidationManager in the script part, but it would be interesting to extend the versatility of the manager.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Gruel</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-6</link>
		<dc:creator>Chris Gruel</dc:creator>
		<pubDate>Tue, 15 Dec 2009 14:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-6</guid>
		<description>I was actually referring to the error message presented, I had already asked before I read above how the error messages are truncated then added to the managedComponent.  I was wondering if you have considered perhaps extending Validator so that it could be completely declared in MXML? This approach could possibly allow staying within the existing flex validation architecture, rather than setting the errorString and focus manually. Thoughts?</description>
		<content:encoded><![CDATA[<p>I was actually referring to the error message presented, I had already asked before I read above how the error messages are truncated then added to the managedComponent.  I was wondering if you have considered perhaps extending Validator so that it could be completely declared in MXML? This approach could possibly allow staying within the existing flex validation architecture, rather than setting the errorString and focus manually. Thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea Bresolin</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-5</link>
		<dc:creator>Andrea Bresolin</dc:creator>
		<pubDate>Sat, 12 Dec 2009 00:44:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-5</guid>
		<description>You&#039;re welcome Chris. If you had 3 validators on a text field and two of them fail, the text field is invalid because a component is considered invalid if at least one of the validators says that it’s not valid.</description>
		<content:encoded><![CDATA[<p>You&#8217;re welcome Chris. If you had 3 validators on a text field and two of them fail, the text field is invalid because a component is considered invalid if at least one of the validators says that it’s not valid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Gruel</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-4</link>
		<dc:creator>Chris Gruel</dc:creator>
		<pubDate>Thu, 10 Dec 2009 14:21:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-4</guid>
		<description>Just out of curiosity, what would happen if you had 3 validators on a text field and 2 out of the three failed?</description>
		<content:encoded><![CDATA[<p>Just out of curiosity, what would happen if you had 3 validators on a text field and 2 out of the three failed?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Gruel</title>
		<link>http://www.devahead.com/blog/2009/11/multiple-validators-on-a-single-component/comment-page-1/#comment-3</link>
		<dc:creator>Chris Gruel</dc:creator>
		<pubDate>Thu, 10 Dec 2009 14:18:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.devahead.com/blog/?p=7#comment-3</guid>
		<description>This is great, thanks for sharing!</description>
		<content:encoded><![CDATA[<p>This is great, thanks for sharing!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

