Monday, 2 July 2012

Data Binding In Flex

Data Binding In Flex

Hello Friends,

                   Today I am going to explain you about data binding, with some examples in flex.

Data Binding :   Basically Data binding is the process of tying the data in one object to another  
                                 object. Data binding requires a source property, a destination property, and a triggering event that indicates when to copy the data from the source to the destination. An object dispatches the triggering event when the source property changes.

Data Binding with Flex :  Flex provide 3 ways to implement data binding. we will discuss 
                                               them one by one :

1st ) The curly Braces ( { } ) method :   Inside the curly braces we give the name of source 

property with the binding expression. When the value of the source property changes, Flex copies the current value of the source property.

Example : 

 
<?xml version="1.0"?>
<!-- binding/BasicBinding.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:TextInput id="myTI" text="Enter text here"/>
    <mx:Text id="myText" text="{myTI.text}"/>
</mx:Application>





2nd)  <mx:binding> tag method

When you use the <mx:Binding> tag, you provide a source property in the <mx:Binding> tag's source property and a destination property in its destination property.

same example with <mx:binding> method :

<?xml version="1.0"?>
<!-- binding/BasicBindingMXML.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:TextInput id="myTI"/>
    <mx:Text id="myText"/>   

    <mx:Binding source="myTI.text" destination="myText.text"/>
</mx:Application>


 


3rd ) In Action Script 

The curly braces syntax and the <mx:Binding> tag both define a data binding at compile time. You can also use ActionScript code to define a data binding at run time.

Example :

<?xml version="1.0"?>
<!-- binding/BasicBindingAS.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    
    <mx:Script>
      <![CDATA[
        import mx.binding.utils.*;

        // Define data binding.
        public function initBindingHandler():void {
            BindingUtils.bindProperty(myText, "text", myTI, "text");
        }
      ]]>    
    </mx:Script>

    <mx:TextInput id="myTI"/>
    <mx:Text id="myText" preinitialize="initBindingHandler();"/>
</mx:Application>


 


In this example, we use the static BindingUtils.bindProperty() method to define the binding. You can also use the BindingUtils.bindSetter() method to define a binding to a function.

Notice in this example that you use the preinitialize event to define the data biding. This is necessary because Flex triggers all data bindings at application startup when the source object dispatches the initialize event.


So friends : try this ..

This is all about one way binding i mean when changing to destination property doesn't effect on source property . 

Thank you :

Pooja Arora
























































































Friday, 29 June 2012

GROUP BY Clause in Oracle

GROUP BY Clause in Oracle

 Hello Friends, 
                     Today I am going to tell you some interesting facts about oracle queries. SQL and Oracle Queries are seems to be same. Query which run fine on Mysql are expected to give same results on oracle , But some constraints are different for Oracle. I am explaining few of them :

GROUP BY clause :  
                                   In Oracle all the fields which are selected , should be in Group By clause  

Take an example to understand this :

QUERY :    Select  st_name, marks, semester from student group by st_name;

In MySql   : query runs fine and give the resultset . 

Oracle   Select  st_name, marks, semester from student group by st_name;

Query Result : ORA-00979: *not a group by expression

Solution :  Select  st_name, marks, semester from student group by st_name, marks, semesters;

 But Group By clause does not contains group function arguments such as SUM, MIN, MAX or COUNT.

Example :  Select  st_name, sum(marks), semester from student group by st_name, semesters;

Example2 : 
                  select department, count(*) as no_of_result from employee where salary >25000 group  by department;



 

Search This Blog

Total Pageviews