{
columnWidth : .5,
layout : 'form',
border : false,
items : [{
name : 'signDate',
fieldLabel : '签发时间',
labelStyle : "text-align: right;",
xtype : 'datefield',
format : 'Y-m-d H:i',
cls : 'key',
allowBlank : true,
menu : new DatetimeMenu(),
anchor : '90%'
}]
}
Action:
public class WeatherAction extends BaseAction {
private String signDate;//签发日期
public String getSignDate() {
return signDate;
}
public void setSignDate(String signDate) {
this.signDate = signDate;
}
/**
*
*/
public void save() throws IllegalAccessException, InvocationTargetException{
ListRange formList = new ListRange();
String message = "";
boolean result = false;
WeatherInfo wi = new WeatherInfo();//this.getModelByForm();
BeanUtils.copyProperties(wi, this);
wi.setSignDate(DateUtil.getDateFromString(signDate,"yyyy-MM-dd HH:mm"));//按指定格式将String转换为Date
LoginUserInfo user = this.getLoginUserInfo();
try{
weatherService.saveOrUpdate(wi,user);
result = true;
}catch(Exception e){
e.printStackTrace();
message = MessageConstants.ACTION_SAVE_SERVICE_FAILURE;
if (e.getCause() instanceof BaseDaoException){
message = MessageConstants.ACTION_SAVE_DB_FAILURE;
}
}
formList.setMessage(message);
formList.setSuccess(result);
this.outJson(formList);
}
}
分享到:
2012-08-21 18:14
浏览 2765
评论