我点击修改数据的时候,需要弹出一个窗口,需要修改的数据放在窗口中,现在后台的数据是取道了,窗口也弹出了,但是没有数据,我估计是url出错了,我只用了struts的execute一个方法实现的CRUD,
后面是用if判断执行操作的
js代码
function doUpdate(operate){
var url = "<%=path%>/test.do?operate=updateInit";
var returnValue = window.showModalDialog(url,"testPage","dialogWidth:500px;status:no;dialogHeight:400px");
//document.forms[0].operate.value = "updateInit"; //我也知道没提交到后台,所以没显示,但是要想提交,应该怎么写?
//document.forms[0].operAtt.value = operate;
document.forms[0].submit();
}
触发事件的代码
<a href="#" onclick="doUpdate('<bean:write name="vo" property="yydm"/>')">修 改</a></td>
解决方案 »
- Number比较的问题
- 这滑动门错哪了?
- validate插件如何使用两个checkbox来验证
- 有关extremecomponents的问题,请高手帮忙给个提示
- 用javascript 可不可以得到客户端的域用户名
- 问一下关于正则中function(a,b,c){}函数的问题
- 用 <jsp:forward page="aa.jsp"/>打开aa.jsp页面的时候,想让aa.jsp页面没有菜单栏,工具栏,和地址栏.该如何做?
- 我的原代码,看能不能实现这个功能?在线~~
- 图片显示,还有这么怪的事情?
- Angular中,怎么让 setter 检测到可变对象(比如一个对象或对象数组)中值的变化?
- [IE,FF]未解决之迷 同一变量,同一方法内,消失了 高手给说说....[100分]
- 请问如何在ajax提交数据的过程中弹出提示框在取得数据后关闭
在打开的窗口用window.dialogArguments获取该参数
给你个例子caller.html <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Caller</title>
<script type="text/javascript">
function openPage(elem, page){
var loading = document.createElement('span');
loading.innerHTML = 'loading';
var arg = {
window: window,
input: document.getElementById('input'),
loading: function(){
elem.parentNode.replaceChild(loading, elem);
},
finished: function(){
loading.parentNode.replaceChild(elem, loading);
}
};
var val = window.showModalDialog(page, arg, 'status:no;dialogWidth:300px;dialogHeight:300px');
!val || alert(val);
}
</script>
</head>
<body>
<a hre="#" onclick="openPage(this, 'input.html');" style="cursor:hand">open</a>
<textarea id="input"></textarea>
</body>
</html>input.html <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Input</title>
<script type="text/javascript">
var arg = window.dialogArguments;
if (arg.loading) arg.loading();
window.onload =function(){
window.returnValue = 'test';
if (arg.finished) arg.finished();
var done = document.getElementById('done'),
input = document.getElementById('input');
done.onclick = function(){
arg.input.value = input.value;
}
}
</script>
</head>
<body>
<textarea id="input"></textarea>
<input type="button" id="done" value="done" />
</body>
</html>
这个时候应该用window.showModalDialog弹出窗口,URL请求后台取出数据
然后在弹出窗口用form提交修改数据,修改完数据后关闭弹出窗口,刷新父页面
但是怎么写?我写到这一步实在是写不下去了,因为我的意思是,要让url里面的请求进入action里面,把数据查询出来,然后放在窗口中,如果用的是DispatchAction很好实现的,但是我现在只用了一个Execute方法,继承的是Action。懂我意思吧,
action里面是if(flag.equals("query")){ 这个里面是查询代码
}
if(flag.equals("del")){
删除代码
}
function doUpdate(operate){
var url = "yymkb.do?operate=updateInit";
var returnValue = window.showModalDialog(url,"test","dialogWidth:500px;status:no;dialogHeight:300px");
//document.forms[0].operate.value = "updateInit";
//document.forms[0].operAtt.value = operate; //这几步我也知道走不到的
document.forms[0].submit();
}action代码 //调试的时候 action代码都没进来
if(dealMethod.equalsIgnoreCase("updateInit")){
String operId = yymkbForm.getOperAtt();
//System.out.println(operId);
YymkbBLH yymkbBLH = new YymkbBLH();
list = yymkbBLH.getPrimaryKeyData(conn, operId);
if(list.size() > 0){
YymkbVO vo = (YymkbVO)list.get(0);
try {
BeanUtils.copyProperties(yymkbForm,vo);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
forward = "updateInit";
}
}