Thursday, June 10, 2010

Flex GoodNess : How to bind TextInput data to a VO behind

Recently , I was looking for a way to update the VO(Value Object) when the TextInput value changes.

With Flex4, We can use Two way binding (usage: @{ } )

With Flex3, We can use the ValueCommit event to update the backend VO.

Value commit event gets fired when the TextInput control value changes through UI interaction or programmitically.

   1: //if we have a datagrid name dg, then a two way binding will look like this, Note: @ symbol is the main one
   2: <s:TextInput text="@{dg.selectedItem.name}"/> 
   3:  
   4: //Also if its Flex 3 ,where two way binding is not available, we can use the value commit event, to update the value ourself
5: <mx:TextInput id="txInput2" text="{dg.selectedItem.email}" valueCommit="txInput2_valueCommitHandler(event)"/>



Enjoy FLexing!!

No comments:

Post a Comment