java struts2:如何弹出一个弹出窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5740494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 12:32:47  来源:igfitidea点击:

struts2 : How to bring up a pop up window

javajspstruts2struts

提问by Vinoth Kumar C M

I am working on a Struts 2 application .I have a JSP page in which there is a normal html table. In one of the columns , I have a link called 'update' . When I click on the 'update' , a new popup windowwill open and the pop up will have many other details of the current row (which means it has to pass through some action and fetch data from database).

我正在开发一个 Struts 2 应用程序。我有一个 JSP 页面,其中有一个普通的 html 表。在其中一栏中,我有一个名为“更新”的链接。当我点击“更新”时,将打开一个新的弹出窗口弹出窗口将包含当前行的许多其他详细信息(这意味着它必须通过一些操作并从数据库中获取数据)。

There is a Submit button in popup , which when clicked , must submit the edited data .

弹出窗口中有一个提交按钮,点击后必须提交编辑后的数据。

How do I create this popup in struts 2?

如何在 struts 2 中创建此弹出窗口?

Should it be the same form as the parent window or a different one ?

它应该是与父窗口相同的窗体还是不同的窗体?

It would be of great help , if you can give links to some tutorial . I am not able to find it in google search .

如果你能提供一些教程的链接,那将会很有帮助。我无法在谷歌搜索中找到它。

回答by anupam

Its a problem related to javascript not struts2.I guess you must be using this syntax in the table definition for link update.

这是一个与 javascript 相关的问题,而不是 struts2。我猜你一定在链接的表定义中使用了这种语法update

<tr><a href="javascript:update('<s:proerty value="anyValueYouwantToSend"/>')">Update</a></tr>

where anyValueYouwantToSendmay be some identifier value you want to send to identify the particular row Then in Javascript

哪里anyValueYouwantToSend可能是您要发送的某些标识符值以标识特定行 然后在 Javascript 中

function update(value){
  var url="myAction?someVariable=value";
  window.open(url,"_blank","directories=no, status=no,width=1400, height=870,top=0,left=0");
}

where myActionwill be the action in which you are going to do your database stuff.In the action mapping of this action you need to give result to a jsp which is going to be your pop-up window.And of course popup window will have a different form to submit, however the update you perform here will be reflected in the parent window only when you refresh it.If you want to reflect these changes without refreshing the parent window you need to write some parent child javascript, which i can help you to do if you want

这里myAction将是你要做你的数据库stuff.In这个动作的动作映射你需要给结果这将是你的课程弹出window.And弹出窗口将有一个jsp动作要提交不同的表单,但是您在此处执行的更新只会在您刷新时反映在父窗口中。如果您想在不刷新父窗口的情况下反映这些更改,您需要编写一些父子 javascript,我可以帮助您如果你愿意