Пример #1
0
 private void findCityAction(
     ConfigData configData, ResponseWriter writer, HttpServletRequest req) {
   try {
     WeatherServiceImpl ws = (WeatherServiceImpl) configData.getWeatherService();
     String searchString = req.getParameter(PARAM_LOCATION);
     if (searchString == null || searchString.length() == 0) {
       writer.addError("Error: missing City or Zip");
     } else {
       Location[] locations = ws.findLocations(searchString);
       for (Location location : locations) {
         Map<String, Object> data = new HashMap<String, Object>();
         data.put(FIELD_KEY, getLocationKey(location));
         data.put(FIELD_NAME, getLocationDescription(location));
         writer.appendToArray("list", data);
       }
     }
   } catch (WeatherServiceException e) {
     writer.addError("Error getting weather service:" + e.getMessage());
     Logging.println("Error getting weather service:" + e.getMessage(), e);
   }
 }