CodeIgniter 4 Multi Language Website

Introduction In this tutorial I am going to show you an example on CodeIgniter 4 multi language website. So the website built on CodeIgniter multilingual or multi-languages will have representations of the same information in different languages. I am going to use three different languages en (English), hi (Hindi), fr (French). You can have more language to make your website internationalization (i18n). CodeIgniter provides several tools to help you localize your application for different languages. While full localization of an application is a complex subject, it’s simple to swap out…

Continue

Spring Singleton Bean with Prototype Bean – Lookup Method Injection

In this tutorial I am going to show you how lookup method injection works in Spring framework. You may face a situation where you need to inject prototype scoped bean into singleton scoped bean. For singleton scoped bean a new instance or object is created and the same is returned each time it is injected or looked up. But for prototype scoped bean a new object or instance is created each time it is injected or looked up. Prototype scoped bean is created at the time of usage. So prototype-scoped…

Continue

How to map Composite Primary Key to Entity Class in JPA Hibernate

In this example I am going to tell you how to map composite primary key to entity class in your JPA Hibernate entity class. Composite primary key is a combination of two or more columns made together as a primary key. Therefore the combination of column values will be as a unique instead of having a single column value as unique. Let’s say you have created a table called user in your database and the user table has three columns – id, name and email. So you don’t want to…

Continue

Find All Paths from Root to Leaf Nodes in Binary Tree using Java

In this example I am going to show you how to find all paths from root to leaf nodes in binary tree. So I am going to find each path from root to leaf node using Java program. A binary tree is a non-linear data structure type tree with at most two children for each parent. Every node in a binary tree has a left and right reference along with data. The type of data can be as per the application’s requirement. The node at the top of the tree…

Continue

How to find Common, Uncommon, Unique Elements in Two ArrayLists using Java

Here I am going to show you how to find common, uncommon, unique elements in two Lists or ArrayLists using Java program. In this program I will show you how to find common, uncommon, unique string elements as well as object elements in two ArrayLists. For identifying the unique string elements is very straight forward but for objects you need to override the equals() and hashCode() methods in your object class otherwise you won’t be able to find. When you are overriding equals() and hashCode() methods then you should consider…

Continue

How to create Custom Immutable Class in Java

Introduction In this tutorial I am going to show you how to create a custom immutable class in Java programming language. Immutable objects are those objects whose states cannot be changed. For example, you can change the state of an object by changing its attribute’s or field’s value. String is an example of the immutable class in Java. There are other examples of immutable class in Java, such as, all primitive wrapper classes are immutable classes – Integer, Byte, Long, Float, Double, Character, Boolean, Short. In Java 8, the Date…

Continue

How to deal with Whitelabel Error Page in Spring Boot Applications

In this tutorial I am going to discuss about what is Whitelabel Error Page and how to deal with Whitelabel Error Page in Spring Boot applications. Spring boot allows you to setup a Spring based application with minimal configurations. Spring MVC applications provide no default (fall-back) error page out of the box but Spring Boot based applications provide a fall-back error page for handling errors. If you want to handle error in Spring based application then you have to set the default error page using SimpleMappingExceptionResolver. When an error or…

Continue

CodeIgniter 4 Transaction Example

Introduction Here I am going to show you an example on CodeIgniter 4 transaction using MySQL database server. You know that transaction is an important part of persistence storage system because you may save, update or delete data from persistence storage any time. When you perform execution of multiple statement across different database or tables or any external system then it is recommended to use transaction otherwise your data may be saved in an inconsistent state. For example, in database you may need to update multiple tables or you may…

Continue

How to display WordPress Popular Posts based on Views

You may want to display popular posts widget in your WordPress site. It serves as a great way to introduce your readers to the most popular contents. The contents you want to show may be posts or pages. Here I am going to show you how you can track and display most popular posts. Having most popular posts displayed on your sidebar widget, it increases the page views and reduces the bounce rate. There are number of plugins available for WordPress CMS (content management system) but there are number of…

Continue

Spring Cloud Bus Example

Here I am going to build an application to show how to use Spring Cloud Bus. Let’s say you have multiple applications reading properties using Spring Cloud Config from centralized configuration files (for example, from Git repository). Spring Cloud Config is where you can have not only your all configurations centrally managed but also you can refresh them dynamically and which in turn can be picked by your referencing applications from the very next moment. So in central configurations using Spring Cloud Config, for each module if there is any…

Continue