Print Shortlink with DirectJNgine

In the previous post, we saw an example of using DirectJNgine. Let’s discuss using to populate a combobox in this post.

We’ll display a list of countries in the combobox. The server side code that returns a list of countries is shown below.

package com.durasoft;

import java.util.ArrayList;
import com.softwarementors.extjs.djn.config.annotations.DirectAction;
import com.softwarementors.extjs.djn.config.annotations.DirectMethod;

public class CountriesStore {
	public ArrayList<Country> loadCountries() {
		ArrayList<Country> countries = new ArrayList<Country>();
		countries.add(new Country("India","New Delhi"));
		countries.add(new Country("US","Washington, D.C"));
		countries.add(new Country("UK","London"));
		return countries;
package com.durasoft;

public class Country {
	private String name;
	private String capital;
	public String getName() {
		return name;
	public void setName(String name) { = name;
	public String getCapital() {
		return capital;
	public void setCapital(String capital) { = capital;
	public Country(String name, String capital) { = name; = capital;
	public Country() {

In Ext JS4 you’ll use class to display the country names in a combobox. The Code is shown below.

	extend : "",
	fields : ["name","capital"]
	var countryStore = Ext.create("",{
			model : "Country",
			autoLoad : true,
			proxy : {
				    type : "direct",
				    directFn : CountriesStore.loadCountries
			renderTo : Ext.getBody(),
			title : " store",
			items : [
			        		store : countryStore,
			        		displayField : "name"

We’ve created a DirectStore instance that uses a “direct” proxy. The directFn property specifies the server-side method loadCountries in CountriesStore class. This proxy uses JsonReader indirectly to parse the data returned from the server. DirectJNgine serializes the data to JSON format automatically.

The complete project created in Eclipse is available at

Leave a Reply