I have a Spring MVC controller that gets called as a redirect based on certain condition. Everything seems to be working fine besides that I would like the returned JSP as modal window. Any suggestions on how to achieve this?
I want myModalWindow.jsp to be returned as modal window or popup.
@RequestMapping( value ="/abc/xyz.html")
public String getMyModal()
{
//Do something here and return modal
return "myModalWindow";
}
Edit 1: This call is made through another controller which in turn is called via an Ajax call.
I have a Spring MVC controller that gets called as a redirect based on certain condition. Everything seems to be working fine besides that I would like the returned JSP as modal window. Any suggestions on how to achieve this?
I want myModalWindow.jsp to be returned as modal window or popup.
@RequestMapping( value ="/abc/xyz.html")
public String getMyModal()
{
//Do something here and return modal
return "myModalWindow";
}
Edit 1: This call is made through another controller which in turn is called via an Ajax call.
Share edited Mar 26, 2013 at 16:05 user2161881 asked Mar 26, 2013 at 15:56 user2161881user2161881 311 gold badge1 silver badge7 bronze badges 2- You need to elaborate on your question. Is the request to your controller made by some Javascript on another page? Assuming this Javascript is using Dojo, you probably want dijit/Dialog. dojotoolkit/reference-guide/1.8/dijit/Dialog.html – Frode Commented Mar 26, 2013 at 16:01
-
You should still elaborate more. Technically, you can put
alert(response.text)
(or similar) in your Ajax call's load/callback function, and you will get a modal window with whatever the server responded. Perhaps you want something more fancy, but it's very difficult to tell without knowing a bit more about your Javascript, the data returned from the server and your general setup/knowledge. Do you already have Dojo set up on your page that makes the Ajax call, for example? – Frode Commented Mar 26, 2013 at 16:18
2 Answers
Reset to default 2Modal window = javascript... you cannot ask the server the open a pop-up in the client's browser. Unless maybe your previous page opens the "/abc/xyz/html" in a new browser window, but it will happen no matter what view your controller returns... and that's not a modal window anyway.
For a real pop-up, all you can do is return a page that will open your modal window (jsp) in the onLoad function :
@RequestMapping( value ="/abc/xyz.html")
public String getMyModal()
{
//Do something here and return modal
return "myPageThatOpensAModalWindow";
}
... and then in myPageThatOpensAModalWindow.jsp :
<html>
<head>
<script>
function loadModalWindow() {
// open your window here
window.open("/myModalWindowURL", ...);
}
</script>
</head>
<body onload="loadModalWindow()">
<h1>Hello World!</h1>
</body>
</html>
Use a Javascript library to load the modal from "/abc/xyz.html". Maybe you need to change the template of that jsp to include only the content of the modal (avoiding, header, footer and main html estructure).
There is no html header, call or whatever that allows you to show a modal on its own, it is usually a div with absolute positioning and a semi opaque layer over the page that blocks all clicks what it is usually used as a modal in web design
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744934121a4601913.html
评论列表(0条)