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;
}
}


Reply With Quote