比如 我的main.jsp页面上有一个选择用户的按钮 点击按钮弹出一个customerSelect.jsp页面 在这个弹出的customerSelect.jsp页面上由2部分组成 上面一半是查找条件表单 可以输入更详细的查找条件进行精确查找 下面一半是查找出来的用户列表 页面刚弹出的时候 下面一半的用户列表是查找条件为空的查找结果 查找用户的Action为CustomerSelectAction选择一个用户 返回父页面main.jsp页面上的选择用户按钮的onclick=window.showModalDialog("customerSelect.jsp", window, "dialogHeight:800px;dialogWidth:600px;center:yes;edge:sunken;");问题是main.jsp上的这个按钮如何让它能执行了CustomerSelectAction后再显示customerSelect.jsp 并将CustomerSelectAction的查找结果显示到customerSelect.jsp页面上我试了在customerSelect.jsp页面上写一个onload事件提交一个隐藏表单来执行CustomerSelectAction 但是执行之后是IE另外又打开了一个窗口来显示customerSelect.jsp的 没有在ModalDialog中显示现在还有个需求就是在ModalDialog中弹出customerSelect.jsp页面的时候 下面一半的用户列表不是查找条件为空的查找结果了 要求能在JS或其他地方给它带上一个“用户类型”的查找条件 让他一弹出来 列表中就是这种给定类型的用户的查找结果 比如有main0.jsp和main1.jsp两个页面 在main0.jsp上点按钮弹出用户类型为0的查找结果 在main1.jsp上点按钮弹出用户类型为1的查找结果 而弹出的这个customerSelect.jsp是公用不变的以下是部分代码
main.jsp:
<body>
    //...其他表单,控件
    <input type="button" value="选择..." onclick="window.showModalDialog('customerSelect.jsp', window, 'dialogHeight:800px;dialogWidth:600px;center:yes;edge:sunken;');">
</body>customerSelect.jsp:
<body>
    <s:form id="selectForm" name="selectForm" action="CustomerSelectAction">
        <s:textfield name="myCustomer.userName"></s:textfield>
        <s:textfield name="myCustomer.mobile"></s:textfield>
        <s:submit value="查找"></s:submit>
    </s:form>    <table border="1" width="700">
        <tr>
            <td>用户名</td>
            <td>手机</td>
        </tr>
        <s:iterator value="customers">
             //Action中查找出来的结果
        </s:iterator>
    </table>
</body>CustomerSelectAction.java:
public class CustomerSelectAction extends ActionSupport {
    private List<Customer> customers = null;
    private Customer myCustomer = null;    //getters,setters    protected String process(Connection con) {
        customers = //将myCustomer做为查找条件 带入数据库中查找
        return "success";
    }
}struts.xml:
<struts>
    <package name = "action" extends = "struts-default">
        <action name = "CustomerSelectAction" class = "....">
            <result name = "success">/customerSelect.jsp</result>
            <result name = "error">/error.jsp</result>
        </action>
    </package>
</struts>

解决方案 »

  1.   

    js啊,只有发送请求才能实现对服务器的调用
    同志搞过ajax的话,自然明白。要是说没有ajax,也可以进行页面刷新,触发请求就好了。
      

  2.   

    window.showModalDialog('customerSelect.jsp', window, 'dialogHeight:800px;dialogWidth:600px;center:yes;edge:sunken;');"
    ===============================================================================================
    你的showModalDialog第二个参数八window放进去干什么?传到对话框里也没用啊?
    ================================================================================================
    贴的东西比较多,凑合着写点,看看对你有没有帮助。
    ===============================================================================================
    弹出得对话框是可以返回值的。
    弹出页面(customerSelect.jsp)
    window.returnValue = "子窗口返回来的值";//设置返回到man.jsp的值父页面(main.jsp)
    function showDialog(){
    //弹出一个showModalDialog,并以returnValue来获取返回值
    var returnValue = window.showModalDialog(url,aInfo,sFeatures);
        if(returnValue!=null){    }
    }
    ================================
      

  3.   


    window我是用来在子页面上往父页面传值的时候用的
    子页面有这样的JS:window.dialogArguments.document.getElementById("").value = ...;往回传值我基本上能搞定 现在主要是弹窗口的时候 页面显示的问题 以及弹窗口的时候 执行Action的问题
      

  4.   


    这样做的话 
    若是在父窗口执行 window.location.href="CustomerSelectAction"; 刷新的是父窗口 我想CustomerSelectAction的结果显示到弹出的ModalDialog子窗口
    若是在子窗口执行 它是打开了一个新页面来显示 也没有显示到ModalDialog子窗口中 
      

  5.   

    onclick = “a()”;
    function a(){
        documents.form[0].action = xxx.do;
        document.form[0].submit();
    }
    若要传参,直接在a()中加就行。
      

  6.   

    JS操作ACTION,建议LZ去看下DWR,那个很不错的项目
      

  7.   

    搞了一下午 发现
    showModalDialog的第一个参数可以写Action 象这样
    window.showModalDialog("CustomerSelectAction.action?myCustomer.type=1", window, "dialogHeight:660px;dialogWidth:640px;");
    问题终于解决了 
    总之还是感谢大家了
      

  8.   

    只要改下你调用的action的名字就应该可以了吧
    难道你共用一个action?
    那试试看innerhtml的写法
      

  9.   

    struts2+json插件 如何在Action bean类接收参数呢