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;



 

Tuesday 12 June 2012

CREATING AND DELETING USER IN ORACLE

CREATING AND DELETING USER IN ORACLE

Oracle with Linux,  Commands

Command for creating a new user in oracle : 

CREATE USER <<user name>> IDENTIFIED BY <<user name>> DEFAULT TABLESPACE <<table space name >> TEMPORARY TABLESPACE  temp QUOTA 50M ON <<table-space name>>;

 In oracle users can be created by the above syntax  ,but before creating a new user one have to create table space .
Table space : Space which is obtained by tables for particular  user.

Syntax for creating TableSpace :


CREATE TABLESPACE  <<table space name >> DATAFILE  'diskb:tbs_<<table space name >>.dat' SIZE 50M REUSE  AUTOEXTEND ON NEXT 50M MAXSIZE 100M;

Now your table space and user space is defined. while connecting your user-name is name of user which you have given in create user command and default password is also same as user- name.

Now you have to give some permissions to the new user :

GRANT create session TO <<user-name>>;
GRANT create table TO <<user-name>>;
GRANT create view TO <<user-name>>;

Now if you want to delete the existing user , the command is :

DROP USER <<user name>> CASCADE;

and if you to delete the user including all its table-space and data files :

firstly drop the user :
DROP USER <<user name>> CASCADE;

 Now after droping user for each including table-space you have to take the table-space offline and then drop it.

ALTER TABLESPACE <<table space name >> OFFLINE;
DROP TABLESPACE <<table space name >> INCLUDING CONTENTS;

Now the user and all of its table -spaces are deleted. and the space assigned to them are free to be re-used.

 


Monday 11 June 2012

INNER CLASSES (static, local and anonymous)

INNER CLASSES (static, local and anonymous)

Inner class (Nested Classes) :  as the name sounds a class which is define inside a class .

syntax for creating inner class : 

[modifiers] class OuterClassName {
    code...
    [modifiers] class InnerClassName {
        code....
    }
}
 
 
Some key points about Inner class :
 
A) An object of an inner class has an implicit reference to the outer class object that instantiated it. Through this pointer, it gains access to any variable of the outer object.
 
B) Inner classes are actually a phenomenon of the compiler and not the JVM.
 
C) The outer class (the class containing the inner class) can instantiate as many number of inner class objects as it wishes, inside it’s code.
 
D) No inner class objects are automatically instantiated with an outer class object.
 
E) If the inner class is static, then static inner class can be instantiated without an outer class instance, otherwise, the inner class object must be associated with an instance of the outer class.
 
F) Inner class code has free access to all elements of the outer class object that contains it, by name, if the inner class has a varible with same name then the outer class’s variable can be accesse like this:
 
<OuterClassName>.this.<variableName>
 
 Inner classes may be defined with following access modifiers : public, protected, private, or with default package access.
Based on these modifiers our next category of inner class is :
 
Static Inner Class

syntax : 

<access-specifier> class OuterClassName {
    public static class <StaticInnerClassName> {
        . . .
    }
    . . .
} 
Difference b/w static and non static inner class :

A) Static members of the outer class are visible to the static inner class, what ever their access level be but Non-static members of the outer class are not available, because there is not instance of the outer class.
B) A static inner class is just like any other inner class, but it dose not have the reference to its outer class object that generated it.    
  
Local Inner Classes
 
 Nested class which is define inside the body of a method of outer class is known as local inner classs.  
 
Syntax :  
 
<access-specifier> class <OuterClassName> {
    code...
    <access-specifier> <return-type> <MethodName>(<arguments>){
        class <LocalInnerClassName>{
            code...
        }
        code...
    }
    code...
}
 Since local inner classes are define inside a method scope of these classes are always restricted to the block in which they are declared.  They are completely hidden from the outside world.
 

Anonymous Inner Classes

Local inner class which is define without name .
 
Syntax :

new SuperType(construction parameters) {
    inner class methods and data
}

 Here, SuperType can be an interface, such as ActionListener; then, the inner class implements that interface. Or SuperType can be a class; then, the inner class extends that class.

Summary of all above Inner classes and compilation :

// Main class
public class Main {
 
    // Inner class Test1
    class Test1 {
    }
 
    // Inner class Test2
    class Test2 {
    }
 
    public static void main(String [] args) {
 
        // Anonymous inner class 1
        new Object() {
        };
 
        // Anonymous inner class 2
        new Object() {
        };
 
        System.out.println("Hello World");
    }
}
  
After Compilation by JVM

Main.class
Main$Test1.class
Main$Test2.class
Main$1.class
Main$2.class
 
Diffrent .class files are generated.
 
 
 

Saturday 7 April 2012

JMETER

JMETER ::: How to use JMETER for Load Testing

Hello Friends,
                     Today i am going to tell you about a new tool i used recently. That is  "JMETER" .
Before starting load testing in Jmeter let me give you a brief introduction about Jmeter.

JMeter is an performance testing tool  produced by  Apache Jakarta 
Although JMeter  focus on web applications but it may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more).
We can use it to make a graphical analysis of performance or to test our server/script/object behavior under heavy concurrent load. 
For your starting step :

As JMeter is a Java application the installation comes basically down to extracting the zip/tar.gz file.
and for starting just double click on "JMeter.Bat" file if you have java installed correctly in your system.

* If you have problem in launching JMeter just edit the JMeter.Bat replace Heap size to '512 ' to 256 .

You’ll see following screen:



 
First we add a “Thread group” to the “Test Plan” via right click onto “Test Plan” as shown in following screenshot:

 Now Click on Thread Group and add a 'Http Request Default '

 


 Now in the server Name or IP text box write the name of the web source which load you want to test. for ex : www.google.com and port let it be default.

After this we add an “HTTP Proxy Server” to the Workbench (as “Non Test Element”) to capture the traffic between your browser and the web site to test. Following screenshot shows how to add the proxy server.






Open the “HTTP Proxy Server” page and change the port if required and set the “Target Controller” to “Test Plan > Thread Group”.

Its almost done now open your browser and tell him to use your proxy server. I will tell you how
Go to Internet Options in tools menu and change the lan settings by adding your proxy server
give the address either ip of your system or "localhost" and port default (8080) .

Now go to the real fun. go to your HttpProxy Server page and click on "Start" at the bottom.

 

Now restart your browser and do some browsing on google.com  and let  the JMeter record all the HTTP requests your browser makes, so make sure you have closed all the other tabs you have open, otherwise you will get a mixture of Ad’s and AJAX requests recorded as well. After you did click through the workflow JMeter show test later you click the “Stop” Button and take a first look what JMeter has recorded for you.




Delete any request that you don’t like by right clicking onto the node and selecting “Remove”.
Now do one more thing add a  Listener which tells us what worked and what not. We use for this “View Results Tree”. This Listener is not good for later use when you want to hammer with multiple threads onto the server. you can also  choose "summary table".







Now we’re ready for our first run, the default settings are fine (in the Menu: Run > Start).





 Now see the results what you have done :



 

If you are running a big load test, remember each Listener keeps a copy of the results in memory so you might be better running a Listener > Simple Data Writer instead which writes the results out to a file. You can then read the file in later into any of the reports.

So friends enjoy with these initial steps.We will go in deep later. 

I hope it was helpful for you .....


Thanks :




















Search This Blog

Total Pageviews