//修改的方法
function editProduct() {
var selectedRows = $("#dg").datagrid('getSelections');
if (selectedRows.length != 1) {
$.messager.alert("系统提示", "请选择一条要编辑的数据!");
return;
}
var row = selectedRows[0];
$("#w").dialog("open").dialog("setTitle", "编辑商品信息");
$("#ff").form("load", row);
url = "${pageContext.request.contextPath}/ProductServlet?method=Edit_P&pid=" + row.pid;
}
//保存
function save() {
$("#ff").form("submit", {
url : url,
success : function(result) {
if (result.errorMsg) {
$.messager.alert("系统提示", result.errorMsg);
return;
} else {
$.messager.alert("系统提示", "保存成功");
$("#w").dialog("close");
$("#dg").datagrid("reload");
}
}
});
}
//update
public String Edit_P(HttpServletRequest req, HttpServletResponse resp) throws SQLException, IOException {
Product p = MyBeanUtils.populate(Product.class, req.getParameterMap());
ProductService productService = new ProductServiceImpl();
productService.edit(p);
return "/admin/product/list.jsp";
}