JavaScript Examples

Before starting an example let us discuss how JavaScript can display the data. JavaScript ways of data display: 1. window.alert(): Display data in an alert box. 2. document.write(): Display data into the HTML output. 3. innerHTML: Display data into an HTML element. 4. console.log(): Display data into the browser console. Javascript in head tag example: … Read more

JavaScript Syntax

JavaScript Syntax specifies the set of rules for constructing a JavaScript program. The is used to write JavaScript statements. The script tag can be used anywhere in the head or body but it is a good practice to use it within the tag. Syntax: <script language=”javascript” type=”text/javascript”> //JavaScript statements </script> Attributes: language: represents the Java … Read more

Spring AOP AspectJ Annotation Configuration Example

AspectJ libraries provides the facility to declare aspect, pointcut etc with the help of annotations. Let us discuss the commonly used AspectJ annotations first. Declaring an aspect: The @Aspect annotation is used to declare a class as an aspect. @Aspect public class AspectModule {   }@Aspect public class AspectModule { } Declaring a pointcut: The … Read more

Spring AOP AspectJ Xml Configuration Example

AspectJ libraries provides the facility to declare aspect, pointcut etc using xml file. Let us discuss the syntax first. Declaring an aspect: The element is used to declare an aspect. The ref attribute is used for bean reference. Declaring a pointcut: The element is used to declare an pointcut. The expression element represents the expression … Read more

Spring AOP tutorial

AOP refers to Aspect Oriented Programming which behaves like OOPs as both provides the concept of modularity. But the difference is it uses aspect rather than class for the unit of modularity. Aspect Oriented Programming breaks down program logic into distinct parts called concerns. A cross-cutting concerns are aspects of a program that affect other … Read more

Spring dependency injection collections

Spring framework provides the facility to inject collection values via constructor or setter method. We can use the following inside the constructor or property element. 1. List. 2. Set. 3. Map. Syntax (constructor based dependency injection): <bean id="testBeanId" class="Test"> <constructor-arg> <list> <value>value1</value> <value>value2</value> <value>value3</value> </list> </constructor-arg> </bean><bean id="testBeanId" class="Test"> <constructor-arg> <list> <value>value1</value> <value>value2</value> <value>value3</value> </list> … Read more

Setter based dependency injection

Setter based dependency injection is a process of passing the dependency to a dependent object via a setter method. Note: 1. For primitive data types use element and for dependent objects use <ref bean="beanId"/><ref bean="beanId"/> 2. Index attribute is used to specify the index of constructor arguments. Example Explanation: We have created two beans “Student” … Read more

Constructor injection type ambiguities in spring

In case of constructor based dependency injection if our class contains multiple constructors with different types and same number of arguments then spring framework cause the constructor injection argument type ambiguities issue. Let us discuss it with below example. Example Explanation: We have created one bean class “Student” which have two constructors with same number … Read more

Spring constructor based injection

Constructor based dependency injection is a process of passing the dependency to a dependent object via a constructor. Note: 1. For primitive data types use element and for dependent objects use <ref bean="beanId"/><ref bean="beanId"/> 2. Index attribute is used to specify the index of constructor arguments. Example Explanation: We have created two beans “Student” and … Read more

Spring dependency injection tutorial

Injection: Injection is a process of passing the dependency to a dependent object. Dependency Injection (DI): Dependency Injection (DI) is a design pattern that implements inversion of control principle for resolving dependencies. It allows a programmer to remove hard coded dependencies so that the application becomes loosely coupled and extendable. Let us discuss object dependency … Read more