Package com.apress.prospring.ch17.web

Examples of com.apress.prospring.ch17.web.IndexController


   * @param name The name
   * @param expirationDate The expiration Date
   * @return Product object with all properties set
   */
  private Product createProduct(int productId, String name, Date expirationDate) {
    Product product = new Product();
    product.setProductId(productId);
    product.setName(name);
    product.setExpirationDate(expirationDate);
   
    return product;
  }
View Full Code Here


  /* (non-Javadoc)
   * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
   */
  protected Object formBackingObject(HttpServletRequest request) throws Exception {
    Product command = new Product();
    int productId = RequestUtils.getIntParameter(request, "productId", 0);
    if (productId != 0) {
      // load the product
      command.setProductId(productId);
      command.setName("loaded");
    }
   
    return command;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.springframework.web.servlet.mvc.AbstractWizardFormController#processFinish(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
   */
  protected ModelAndView processFinish(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
    Product product = (Product) command;

    System.out.println("Register " + product);
    return null;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
   */
  protected Object formBackingObject(HttpServletRequest request) throws Exception {
    Product command = new Product();
    int productId = RequestUtils.getIntParameter(request, "productId", 0);
    if (productId != 0) {
      // load the product
      command.setProductId(productId);
      command.setName("loaded");
    }
   
    return command;
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
   */
  public void validate(Object obj, Errors errors) {
    Product product = (Product)obj;
    if (product.getName() == null || product.getName().length() == 0) {
      errors.rejectValue("name", "required", "");
    }
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
   */
  public void validate(Object obj, Errors errors) {
    Product product = (Product)obj;
    if (product.getName() == null || product.getName().length() == 0) {
      errors.rejectValue("name", "required", "");
    }
  }
View Full Code Here

TOP

Related Classes of com.apress.prospring.ch17.web.IndexController

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.