Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a new window with reduced size in grails

I have a controller action named showcontacts which is called when a link is clicked.The action showcontacts calls a java method that fetches some contacts from web service,after accepting params as parameter.These all are working fine.Now i have to open a window of reduced size(like a popup) from this action as a new template.How can i do this?Plz help.what i tried is as follows:

controller:customer

action:

def showcontacts={
    log.info(params.tdc+params.companyid+params.companytype)
    def contact=server.util.SOAPClientSAAJ.showContacts(params);
    render view:'showcontacts', model:[contact:contact]
}

I tried like this in showcontacts.gsp:

<html>
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jqueryui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
 $(function() {
 $( "#dialog" ).dialog();
 });
</head>
<body>
<g:if test="${contact}">
<div id="dialog" title="Contacts">
 ${contact.firstName}
</div>
</g:if>

</body>

</html>

Eventhough the new window is appearing its hiding the other window(not like a popup).

OR simply stated my requirement is how to call window.Open in javascript from my view showcontacts???

like image 644
PassionateProgrammer Avatar asked Dec 06 '25 03:12

PassionateProgrammer


1 Answers

You can open a new window of reduced size like this.

<a href="javascript:void(0)" onclick="javascript:asd()">asd</a>
<script>
function asd(){
window.open("${g.createLink(controller: 'testController', action: 'testAction', params: [name:'hello Vivek'])}",'', 'width=200,height=100');
}
</script>

If you want to open it in new tab, you can try this.

<g:link controller="testController" action="testAction" target="_blank">Test</g:link>

Enjoy..

like image 174
user1791574 Avatar answered Dec 07 '25 17:12

user1791574