Results 1 to 2 of 2

Thread: application cann't access onSubmit of SimpleFormController

  1. #1
    Join Date
    Mar 2005
    Posts
    4

    Default application cann't access onSubmit of SimpleFormController

    application can access formBackingObject of SimpleFormController , but it cann't call onSubmit, and directness call "successView":

    <bean id="nationValidator" class="system.nationValidator"/>
    <bean id="nationaddFormControllerid" class="system.nationFormController">
    <property name="sessionForm"><value>true</value></property>
    <property name="commandName"><value>nationbean</value></property>
    <property name="commandClass"><value>system.nationbean</value></property>
    <property name="validator"><ref bean="nationValidator"/></property>
    <property name="formView"><value>system/test/nationInsert</value></property>
    <property name="successView"><value>system/nationdo2</value></property> <property name="nationbeanManager">
    <ref bean="nationbeanserverid"/>
    </property>

    </bean>

    package system;

    import java.io.Serializable;
    import org.springframework.validation.Validator;
    import org.springframework.validation.Errors;

    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;

    public class nationValidator implements Validator {

    //private int DEFAULT_MIN_PERCENTAGE = 0;
    //private int DEFAULT_MAX_PERCENTAGE = 50;
    //private int minPercentage = DEFAULT_MIN_PERCENTAGE;
    //private int maxPercentage = DEFAULT_MAX_PERCENTAGE;

    /** Logger for this class and subclasses */
    protected final Log logger = LogFactory.getLog(getClass());


    public boolean supports(Class clazz) {
    return clazz.equals(nationbean.class);
    }
    /*
    public boolean supports(Class clazz) {
    return nationbean.class.isAssignableFrom(clazz);
    }
    */
    public void validate(Object obj, Errors errors) {
    nationbean beanobj = (nationbean) obj;
    if (beanobj == null) {
    errors.rejectValue("object", "error.objectnotvalue", null, "对象没有值,请重新打开操作.");
    }
    else {
    System.out.println("BK_Nation_Name:="+beanobj.getB K_Nation_Name());
    if(beanobj.getBK_Nation_Name()==null || beanobj.getBK_Nation_Name().equals("")){
    errors.rejectValue("BK_Nation_Name", "error.namerepeate", null, "名称 not null 或编码重复.");
    System.out.println("名称 not null ");
    }
    }

    System.out.println("888888888888888888888888888888 888888888");
    }


    }


    public class nationFormController extends SimpleFormController {

    private nationbeanManager prodMan;
    private nationbeanManagerI prodManIojb;

    public ModelAndView onSubmit(HttpServletRequest request,HttpServletResponse response,Object command,BindException ex)
    throws ServletException {


    //取值
    nationbean nationbeanobj= (nationbean) command;

    List query_resultList=null;

    //logger.info("Increasing prices by " + increase + "%.");

    //prodMan.increasePrice(increase);

    String now = (new java.util.Date()).toString();
    //logger.info("returning from PriceIncreaseForm view to " + getSuccessView() +" with " + now);
    //System.out.println("query_resultList="+query_resul tList.size());
    Map myModel = new HashMap();
    myModel.put("now", now);
    myModel.put("query_results", query_resultList);
    System.out.println("======query_resultList99999999 999999999999999999999999999=========");
    return new ModelAndView("system/test/nationbrows","results_obj",myModel);
    }

    protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    nationbean nationbeanobj= new nationbean();
    System.out.println("Me can vister this page");
    return nationbeanobj;

    }

    }

  2. #2
    Join Date
    Mar 2005
    Posts
    4

    Default Re: application cann't access onSubmit of SimpleFormControll

    I have find the error: it cann't use "public ModelAndView onSubmit(HttpServletRequest request,HttpServletResponse response,Object command,BindException ex) throws ServletException { " ,
    must use "public ModelAndView onSubmit(Object command)
    throws ServletException { "

    if i have some other parameter .e.g <input type="hidden">, How to get it.

    use:

    protected void onBind(HttpServletRequest request, Object command) throws Exception {
    tjj1 = request.getParameter("tjj1");
    }

    or

    protected void initBinder(HttpServletRequest request,ServletRequestDataBinder binder) throws Exception {
    tjj = request.getParameter("tjj");
    }

    up method is in reason?? if have any other way to get these values ??

Similar Threads

  1. SimpleFormController onSubmit()
    By Frizzi in forum Web
    Replies: 15
    Last Post: Dec 15th, 2010, 09:56 AM
  2. SimpleFormController not do onSubmit
    By heleno_alves in forum Web
    Replies: 2
    Last Post: Oct 18th, 2005, 07:22 AM
  3. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  4. Replies: 1
    Last Post: Aug 26th, 2005, 04:33 AM
  5. Questioning the core component
    By Martin Kersten in forum Swing
    Replies: 6
    Last Post: Feb 21st, 2005, 03:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •