コード例 #1
0
  protected ActionForward performAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String forward = FWD_SUCCESS;
    request.setAttribute(ALLOW_EDITS_KEY, "true");
    String city = request.getParameter("city");
    String state = request.getParameter("state");
    // bugzilla 1895 changed request parameter to zipCode for consistancy
    String zip = request.getParameter("zipCode");

    BaseActionForm dynaForm = (BaseActionForm) form;

    // initialize the form
    dynaForm.initialize(mapping);

    CityStateZipDAO cityStateZipDAO = new CityStateZipDAOImpl();
    CityStateZip cityStateZip = new CityStateZip();
    cityStateZip.setState(state);
    cityStateZip.setCity(city);
    cityStateZip.setZipCode(zip);
    List validCombos = cityStateZipDAO.getValidCityStateZipCombosForHumanSampleEntry(cityStateZip);
    String selectedCombo = "0";

    PropertyUtils.setProperty(dynaForm, "validCombos", validCombos);
    PropertyUtils.setProperty(dynaForm, "selectedCombo", selectedCombo);

    return mapping.findForward(forward);
  }
  protected ActionMessages validateZipCity(ActionMessages errors, String zipCode, String city)
      throws Exception {
    // bugzilla 1545
    CityStateZipDAO cityStateZipDAO = new CityStateZipDAOImpl();
    CityStateZip cityStateZip = new CityStateZip();

    // use 5-digit zipcode for validation
    String zc5Dig = null;
    zc5Dig = zipCode.substring(0, 5);
    cityStateZip.setZipCode(zc5Dig);
    cityStateZip.setCity(city);

    cityStateZip = cityStateZipDAO.getCityStateZipByCityAndZipCode(cityStateZip);

    if (cityStateZip == null) {
      errors.add(
          ActionMessages.GLOBAL_MESSAGE,
          new ActionError("humansampleone.validation.zipCity", null, null));
    }

    return errors;
  }