Flex/AS3 Setting default value for empty form
Currently I have a form in a window like this:
<mx:Form>
<mx:FormItem label="Reference">
<mx:TextInput id="reference" width="100%"/>
</mx:FormItem>
<mx:FormItem label="Command">
<mx:TextInput id="command" width="100%"/>
</mx:FormItem>
<mx:FormItem label="Command Field">
<mx:TextInput id="commandField" width="100%"/>
</mx:FormItem>
<mx:FormItem label="Parameter">
<mx:TextInput id="parameter" width="100%"/>
</mx:FormItem>
<mx:FormItem label="Extra Command">
<mx:TextInput id="commandExtra" width="100%"/>
</mx:FormItem>
<mx:FormItem label="Sequence Number">
<mx:TextInput id="seq" width="100%"/>
</mx:FormItem>
</mx:Form>
Is there any way to change the default value of a blan开发者_开发技巧k form entry from null
to some other value?
You could write a function that replaces the functionality of TextInput.text
Something along the lines of:
public function set text():String {
return formatText(_text);
}
private function formatText(textToFormat:String):String {
return (textToFormat == null)? "" : textToFormat;
}
Which, of course could also be simplified to:
public function set text():String {
return (_text == null)? "" : _text;
}
This would require that the _text property of FormItem is protected (and not private). If that's not the case, there are ways to work around it.
Clearly, there are better ways to solve this problem but I just wanted to throw out an idea.
Hope it helps in some way or form,
--gMale
精彩评论