Search in sources :

Example 1 with GetCountries

use of org.activityinfo.legacy.shared.command.GetCountries in project activityinfo by bedatadriven.

the class NewDbDetailsPage method loadCountries.

private void loadCountries() {
    loadCountries.setEnabled(false);
    countryField.setShowValidationMessage(false);
    dispatcher.execute(new GetCountries(), new AsyncCallback<CountryResult>() {

        @Override
        public void onFailure(Throwable caught) {
            loadCountries.setEnabled(true);
            countryField.showValidationMessage(I18N.CONSTANTS.failedToLoadCountries());
            loadCountries.setVisible(true);
        }

        @Override
        public void onSuccess(CountryResult result) {
            loadCountries.setVisible(false);
            for (CountryDTO countryDTO : result.getData()) {
                country.addItem(countryDTO.getName(), Integer.toString(countryDTO.getId()));
            }
            country.update();
        }
    });
}
Also used : CountryResult(org.activityinfo.legacy.shared.command.result.CountryResult) CountryDTO(org.activityinfo.legacy.shared.model.CountryDTO) GetCountries(org.activityinfo.legacy.shared.command.GetCountries)

Example 2 with GetCountries

use of org.activityinfo.legacy.shared.command.GetCountries in project activityinfo by bedatadriven.

the class RootResource method getCountries.

@GET
@Path("/countries")
@JsonView(DTOViews.List.class)
@Produces(MediaType.APPLICATION_JSON)
public List<CountryDTO> getCountries() {
    QueryModel model = new QueryModel(CountryTable.FORM_CLASS_ID);
    model.selectField(CountryTable.CODE_FIELD_ID).as("code");
    model.selectField(CountryTable.NAME_FIELD_ID).as("name");
    return dispatcher.execute(new GetCountries()).getData();
}
Also used : GetCountries(org.activityinfo.legacy.shared.command.GetCountries) QueryModel(org.activityinfo.model.query.QueryModel) JsonView(org.codehaus.jackson.map.annotate.JsonView)

Aggregations

GetCountries (org.activityinfo.legacy.shared.command.GetCountries)2 CountryResult (org.activityinfo.legacy.shared.command.result.CountryResult)1 CountryDTO (org.activityinfo.legacy.shared.model.CountryDTO)1 QueryModel (org.activityinfo.model.query.QueryModel)1 JsonView (org.codehaus.jackson.map.annotate.JsonView)1