Wednesday, November 21, 2007

Forcing Error Pop-Up on a Flex Control without a Validator

In my previous post about ToolTipManager and its delays, I showed how error pop-ups from ToolTipManager looks like. I'll repeat the image here:

This pop-up is normally a result of a validator. But actually, you can, in a very simple way, force such a pop-up to appear quite easily. You simply assign the errorString property on a flex component to a non-empty string. Like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="">

private function setError() : void {
data.errorString = "this is an error popup";

private function clearError() : void {
data.errorString = "";

<mx:TextInput id="data" text="Enter data here"/>

<mx:Button label="Set error" click="setError()"/>
<mx:Button label="Clear error" click="clearError()"/>

That was easy! The errorString property is defined on UIComponent, so it is quite universally available on the UI components of the flex framework.

No comments: