Select Loader demo

This page displays the SelectLoader mixin.
Notice the t:mixins associated to the t:targetId attribute.

In Action
Submitted country label :
Submitted city label :

TML Source code

			<t:select t:id="country" t:mixins="exanpe/selectLoader" t:targetId="city"  
					  model="countryModel" value="countryValue" encoder="countryEncoder"/>
			<t:select t:id="city" model="cityModel" value="cityValue"/>
		Submitted country label : ${countryValue?.name}<br/>
		Submitted city label : ${cityValue?.name}<br/>

Java code

    private SelectModelFactory selectModelFactory;

    private SelectModel countryModel;

    private Country countryValue;

    private SelectModel cityModel;

    private City cityValue;

    private DataService dataService;

    public void ini()
        // invoke my service to find all countries, e.g. in the database
        List<Country> countries = dataService.getCountryList();

        // create a SelectModel from my list of countries
        countryModel = selectModelFactory.create(countries, "name");

        // init cityModel

    @OnEvent(value = ExanpeEventConstants.SELECTLOADER_EVENT)
    public SelectModel populateSelect(String value)
        cityModel = selectModelFactory.create(dataService.getCitiesByCountry(value), "name");
        return cityModel;

    private void loadCitySelect()
        if (countryValue == null)
            cityModel = new SelectModelImpl(new OptionModelImpl[0]);
            cityModel = populateSelect(countryValue.getId());

    public ValueEncoder<Country> getCountryEncoder()
        return new CountryEncoder(dataService);