admin管理员组文章数量:1336632
I am trying to call a method in action class in javascript function on button click event which is in jsp.I am using struts 2.could you tell me how to do this? There is a function in ListAlgorithmAction Class which I want to call when the user clicks submit button.
function alertselected (){
var x = document.getElementById ( "select_name" ).selectedIndex;
var y = document.getElementById ( "select_name" ).options;
var id = y [x].index;
redirect(id);
}
function redirect(x){
document.getElementById ( "param_ID" ).value = x;
document.forms ["./ListAlgorithmAction"].submit ();
}
I am trying to call a method in action class in javascript function on button click event which is in jsp.I am using struts 2.could you tell me how to do this? There is a function in ListAlgorithmAction Class which I want to call when the user clicks submit button.
function alertselected (){
var x = document.getElementById ( "select_name" ).selectedIndex;
var y = document.getElementById ( "select_name" ).options;
var id = y [x].index;
redirect(id);
}
function redirect(x){
document.getElementById ( "param_ID" ).value = x;
document.forms ["./ListAlgorithmAction"].submit ();
}
Share
Improve this question
edited Aug 30, 2012 at 19:13
Pigueiras
19.4k10 gold badges66 silver badges87 bronze badges
asked Aug 30, 2012 at 18:42
SohamSoham
912 gold badges6 silver badges15 bronze badges
2 Answers
Reset to default 3I do not think this is something related to Struts2 ,since struts2 is independent of the way you call action class be it by java-script form submit,ajax or by simple form submit.
i believe you have some form in your jsp like
<s:form action="myAction" name="myForm">
some data
</s:form>
on click you can do something like
function redirect(x){
document.getElementById("param_ID").value=x;
document.myForm.action="ListAlgorithmAction";
document.myForm.submit();
}
This is just solution based on your inputs and there can be many more if you able to define your problem more
For similar implementations we used to use http://directwebremoting/dwr/index.html (DWR). You can try that.. if you have big implementation i would suggest you to integrate this framework
本文标签: how to call method in action class in javascript using struts2 frameworkStack Overflow
版权声明:本文标题:how to call method in action class in javascript using struts2 framework? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742414074a2470369.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论